whenever anyone uses my camp thingy, it is the owner of the thingy who starts to dance. I know why it happens: i ask for permission debt and trigger animation together, so that i can have both when i need to make the person dance.
point is: i cant figure out how to make the permission for debt stick on it and still get permissions for starting an animation on the person who is sitting....
CODE
//camp script by Naryu Yue
//==================== setings ============================
integer cash = 4; //lindens to pay out
integer delay = 15; //time to wait between pays in minutes
integer maxCamp = 2; //how many times can a person be paid by the script per sit
//=========================================================
integer count = 0; //how many times the person has already been paid
integer permissionResult = FALSE;
key agentKey = NULL_KEY;
default
{
on_rez(integer param)
{
llRequestPermissions(llGetOwner(), PERMISSION_DEBIT|PERMISSION_TRIGGER_ANIMATION);
}
state_entry()
{
llSetSitText("Camp!");
llSitTarget(<0,0,0.1>,<0,0,0,1>);
}
changed(integer change)
{
if (change & CHANGED_LINK)
{
key agent = llAvatarOnSitTarget();
if ( agentKey == NULL_KEY && agent != NULL_KEY ) //someone is dancing
{
agentKey = agent;
llStopAnimation("sit");
llStartAnimation("The Butt Shake Dance");
llSetTimerEvent(delay*60);
}
else if ( agentKey != NULL_KEY && agent == NULL_KEY) //person has gone away
{
if (permissionResult) //but the script has been initialized already
{
//Stop animating the avatar
llStopAnimation("The Butt Shake Dance");
llSetTimerEvent(0);
agentKey = NULL_KEY;
count = 0;
}
//llResetScript();
}
}
}
run_time_permissions(integer value)
{
if (value == PERMISSION_DEBIT|PERMISSION_TRIGGER_ANIMATION)
{
permissionResult = TRUE;
llSay(0, "Sistema inicializado");
}
}
timer()
{
llGiveMoney(agentKey, cash);
count += 1;
if (count==maxCamp)
{
llUnSit(agentKey);
}
}
}