Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Prevent new avatar to disrupt the using avartar on chair

Demon Lilliehook
Registered User
Join date: 8 May 2007
Posts: 25
06-25-2007 19:04
how can i prevent a new avatar from disrupting the using avatar.
i tried all sort of possibilities, but none sofar worked.




changed(integer change)
{
// something changed
if (change & CHANGED_LINK)
{
// and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY && reciever == NULL_KEY)
{
if(llAvatarOnSitTarget() != reciever && busy == TRUE)
{
Say("Sorry, "+llKey2Name(llAvatarOnSitTarget())+" chair in use";);
return;
}
reciever = llAvatarOnSitTarget(); // store sitting avatar's key
LP = llKey2Name(reciever);
SetHoovertest(LP + "\nYou earned: L$"+(string)campmoney + " Sofar";);
llSetTimerEvent(camptime);
busy = TRUE;
}
else if( reciever != NULL_KEY)
{
// if the avatar has gotten up
if(campmoney > 0)
{
// give the avatar the amount of money he has earned.
GiveMoney(reciever,campmoney);
SetInactive();
}
}
}
}


SetInactive(); <--- Resets busy to FALSE.

( click QUOTE te see the text better formatted).

kind regards,

Demon
Noctua Janus
Registered User
Join date: 22 Mar 2007
Posts: 29
06-25-2007 22:48
Haven't tested this, but I guess it should work for you. Just stick with one additional variable to decide if the chair is occupied.

From: someone

changed(integer change)
{
// something changed
if (change & CHANGED_LINK)
{
// and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY && busy == FALSE)
{
busy = TRUE;
reciever = llAvatarOnSitTarget(); // store sitting avatar's key
LP = llKey2Name(reciever);
SetHoovertest(LP + "\nYou earned: L$"+(string)campmoney + " Sofar";);
llSetTimerEvent(camptime);
}
else if(llAvatarOnSitTarget() != NULL_KEY && busy == TRUE)
{
llSay(0,"Sorry, "+llKey2Name(llAvatarOnSitTarget())+" chair in use";);
}
else
{
// the avatar has gotten up
if(campmoney > 0)
{
// give the avatar the amount of money he has earned.
GiveMoney(reciever,campmoney);
SetInactive();
}

}
}
Demon Lilliehook
Registered User
Join date: 8 May 2007
Posts: 25
thnx
06-26-2007 11:08
thnx, it works.

else if(llAvatarOnSitTarget() != NULL_KEY && busy == TRUE)
{
llSay(0,"Sorry, "+llKey2Name(llAvatarOnSitTarget())+" chair in use";);
}


but llKey2Name(llAvatarOnSitTarget()) , returns the name of the avatar currently using the chair.
not the avatar trying to get on it.

it does pay the correct avatar.


thnx for
BamBam Sachertorte
floral engineer
Join date: 12 Jul 2005
Posts: 228
06-26-2007 13:55
Have the using avatar sit on the root prim. On a child prim put in a script that has a sit target but always unsits whoever sits on it. Since there is more than one prim with a sit target in your chair the root prim will never have more than one avatar sitting on it. Your script in the root prim can assume that whoever is sitting on the root prim is the using avatar.