Hi I have a pay max amount script (see below0 I would like it to count in hover text how many times it has paid out so i know when to reset the script c
an anyone help me with this?
Thank you ricky Wirefly
// V2 //
integer total = 100; // Total amount the script is allowed to give away.
integer gift = 1; // Amount to give per gift.
/////////////////////////////////////////////
key owner; // Used to store the owners UUID.
integer perms; // Used to store if permissions were granted.
integer given; // Used to count the total amount given.
list agents = []; // Used to store the UUIDs of the agents who have had a gift.
default
{
on_rez(integer param)
{
llResetScript(); // Clear all lists and reset all variables. This action will also clear the permissions.
}
changed(integer change)
{
if(change & CHANGED_OWNER) // If the script or object changes ownership the script will not be able
llResetScript(); // to deduct cash from the previous owners account.
}
state_entry()
{
owner = llGetOwner(); // Store the owners key.
llRequestPermissions(owner, PERMISSION_DEBIT); // !! THIS MEANS IT WILL TAKE YOUR MONEY !!
}
run_time_permissions(integer perm)
{
if(perm & PERMISSION_DEBIT) // Have we got the permissions we requested?
perms = TRUE; // Store the result of success.
else
llRequestPermissions(owner, PERMISSION_DEBIT); // If not we ask for them again.
}
touch_start(integer nd)
{
while(nd && (given < total) && perms) // Have we got permissions? Have we given less than the total allowed?
{
key agent = llDetectedKey(--nd); // grab the UUID of the touching agent.
if(llListFindList(agents, [agent]) == -1) // Have we already given a gift to this agent?
{
agents += [agent]; // Add the agent to the list.
llGiveMoney(agent, gift); // Give the gift to the agent who touched us.
if((given += gift) == total) // Increment the amount given by the amount just given and check if we have maxxed out yet.
state maxxed_out; // If maxxed out, go to a state with no touch_ event so we are not repeatedly messaged.
}
}
}
}
state maxxed_out
{
state_entry()
{
llInstantMessage(owner, "The total amount this object can give away has been given." + // Contact the owner.
"\nTo allow more to be given the script must be reset.");
}
}