[PHP]
integer campmoney = 0; // Initial amount to grant someone upon the VERY first sit after first rez. (Think, Special bonus)
integer campadd = 1; // Payout amount
integer camptime = 600; // Payout time in seconds (Script USES this)
string camptimeM = "10 minutes"; // Payout time in minutes (Attract SAYS this)
integer payoutLimit = 100; // Payout Limit before chair auto shutsdown
integer totalPayout;
string receiver = NULL_KEY; // key of Sitter
// Modifications for Animation
vector pos = <0,0,1.1>; //adjust the (x,y,z) position to fit object
string sittext = ""; // Adjust this to your needs but keep it short!
string animation; // The first animation in object will be used
GetParameters()
{
string str = llGetObjectDesc();
list ldata = llParseString2List(str, ["/"], [""]);
if(llGetListLength(ldata) == 5)
{
campmoney = llList2Integer(ldata,0);
camptime = llList2Integer(ldata,1);
campadd = llList2Integer(ldata,2);
payoutLimit = llList2Integer(ldata,3);
totalPayout = llList2Integer(ldata,4);
}
}
SetInactiveText()
{
llSetText("Group Members sit here for free money,\nL$"+(string)campadd+" every "+camptimeM,<0,1,0>,1); // Set the hovertext to attract mode
}
SetActiveText()
{
llSetText("You have earned: L$"+(string)campmoney,<1,1,1>,1); // Setting hovertext to current amount earned
}
SetInactive()
{
receiver = NULL_KEY; // forget who the receiver was
campmoney = 0; // reset earning count to 0
SetInactiveText();
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
// States
default
{
state_entry()
{
GetParameters();
llSetTimerEvent(0);
animation = llGetInventoryName(INVENTORY_ANIMATION,0);
llSitTarget(pos, ZERO_ROTATION);
SetInactiveText();
llSetSitText(sittext);
}
on_rez(integer num) { llResetScript(); }
changed(integer change)
{
// something changed
if (change & CHANGED_LINK)
{
// and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY && receiver == NULL_KEY)
{
// if Avatar key isn't empty, somebody is sitting on me
if ( llSameGroup(llAvatarOnSitTarget()) ) // Check that the sitter is of the same group as the prim
{
// if so, allow them to sit and start the payments
receiver = llAvatarOnSitTarget(); // store sitting avatar's key
SetActiveText();
llSetTimerEvent(camptime); // amount of time between payments in seconds
llRequestPermissions(receiver, PERMISSION_TRIGGER_ANIMATION );
}
else
{
// if not, boot them off with an explanation.
llSay(0, "Group members only, sorry."
; llSay(0, "If you are a group member, please \"wear your tags\" by making the group active.."
; llUnSit(llAvatarOnSitTarget()); // unsit him or her
}
}
else if( receiver != NULL_KEY )
{
// if the avatar has gotten up
llStopAnimation(animation);
if(campmoney > 0)
{
// give the avatar the amount of money he has earned.
llMessageLinked(LINK_THIS, campmoney,"PAY",receiver);
}
SetInactive();
}
}
else if (change & CHANGED_INVENTORY)
{
//
// reset script if inventory changes
//
llResetScript();
}
}
timer()
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
SetActiveText();
if (llAvatarOnSitTarget() == NULL_KEY)
{
// Noone's sitting on me, reset the vars
SetInactive();
}
integer temp = totalPayout + campmoney;
if(temp >= payoutLimit)
{
llSay(0, "I'm sorry but you have reached the payout limit"
; llUnSit(llAvatarOnSitTarget()); // unsit him or her
}
}
run_time_permissions(integer perms)
{
if( (perms & PERMISSION_TRIGGER_ANIMATION) == PERMISSION_TRIGGER_ANIMATION)
{
llStopAnimation("sit"
; llStartAnimation(animation);
}
}
link_message(integer sender_num, integer num, string str, key id)
{
if("DISABLED" == str)
{
state Disabled;
}
else if("RESET" == str)
{
llResetScript();
}
}
}
state Disabled
{
state_entry()
{
llSetText("Sorry not in Use",<1,0,0>,1); // Set the hovertext to off
}
link_message(integer sender_num, integer num, string str, key id)
{
if("RESET" == str) llResetScript();
}
}
[/PHP]

