CODE
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)
string reciever = NULL_KEY; // key of Sitter
string _Animation;
list MenuChoices = ["On","Off","Payout","Bonus","Time"];
list AmountChoices = ["1$","2$","3$","4$","5$","10$"];
list BonusChoices = ["1$ Bonus","2$ Bonus","3$ Bonus","4$ Bonus","5$ Bonus","10$ Bonus"];
list TimerChoices = ["1 minute","2 minutes","3 minutes","4 minutes","5 minutes","10 minutes","15 minutes"];
integer Listening = 0;
integer listenchannel = 0;
UpdateListen(key id)
{
CancelListen();
Listening = llListen(listenchannel,"",id,"");
llSetTimerEvent(30);
}
CancelListen()
{
if(Listening > 0) llListenRemove(Listening);
Listening = 0;
llSetTimerEvent(0);
}
// Owner Conversation Dialog
ShowMainMenu(key id)
{
string text = "Main Menu\nPlease Select an Option";
// finally show the dialog
llDialog(id,text,MenuChoices,listenchannel);
UpdateListen(id);
}
ShowPayoutMenu(key id)
{
string text = "Payout Menu\nPlease Select an amount";
// finally show the dialog
llDialog(id,text,AmountChoices,listenchannel);
UpdateListen(id);
}
ShowBonusMenu(key id)
{
string text = "Bonus Menu\nPlease Select an amount";
// finally show the dialog
llDialog(id,text,BonusChoices,listenchannel);
UpdateListen(id);
}
ShowTimerMenu(key id)
{
string text = "Timer Menu\nPlease Select a time period";
// finally show the dialog
llDialog(id,text,TimerChoices,listenchannel);
UpdateListen(id);
}
SetInactive()
{
reciever = NULL_KEY; // forget who the receiver was
campmoney = 0; // reset earning count to 0
llSetText("sit here for free money,\nL$" + (string)campadd + " every "+camptimeM,<0,1,0>,1); // change hovertext back to attract mode
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
// States
default
{
state_entry()
{
if(llGetInventoryNumber(INVENTORY_ANIMATION) >0)
{
_Animation = llGetInventoryName(INVENTORY_ANIMATION,0);
}
else
{
_Animation = "sit";
}
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT); //Ask my owner for permission to give money and assume it suceeds
}
on_rez(integer num)
{
llResetScript();
}
touch_start(integer t)
{
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_DEBIT)
{
state Running;
}
else
{
llOwnerSay("You need to give premisions to debit to cud use this chair");
}
}
}
state Running
{
state_entry()
{
llSetText("sit here for free money,\nL$"+(string)campadd+" every "+camptimeM,<0,1,0>,1); // Set the hovertext to attract mode
llSitTarget(<0.4, 0, 0.6>, ZERO_ROTATION); // needed for llAvatarOnSitTarget to work
}
on_rez(integer t)
{
llResetScript();
}
changed(integer change)
{
// something changed
if (change & CHANGED_LINK)
{
// and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY && reciever == NULL_KEY)
{
llRequestPermissions(llGetOwner(),PERMISSION_TRIGGER_ANIMATION); // we start animation!
// 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
reciever = llAvatarOnSitTarget(); // store sitting avatar's key
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // Setting hovertext to current amount earned
llSetTimerEvent(camptime); // amount of time between payments in seconds
}
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( reciever != NULL_KEY )
{
// if the avatar has gotten up
if(campmoney > 0)
{
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
}
llStopAnimation(_Animation);
SetInactive();
}
}
}
timer()
{
campmoney = campmoney+campadd; // current amount + xL$ per camptime
llSetText("Money: L$"+(string)campmoney,<0,1,0>,1); // update hovertext with currently earned amount
if (llAvatarOnSitTarget() == NULL_KEY)
{
// Noone's sitting on me, reset the vars
SetInactive();
}
}
run_time_permissions(integer perm)
{
if (perm & PERMISSION_TRIGGER_ANIMATION)
{
llStartAnimation(_Animation);
}
}
touch_start(integer total_number)
{
// Owner
key id = llDetectedKey(0);
if( (id == llGetOwner()))
{
state Menu;
}
}
}
state Menu
{
state_entry()
{
ShowMainMenu(llGetOwner());
}
on_rez(integer num) { state default; }
timer()
{
CancelListen();
state Running;
}
on_rez(integer t)
{
llResetScript();
}
listen( integer channel, string name, key id, string message )
{
CancelListen();
if("On" == message)
state Running;
else if("Off" == message)
state Disabled;
else if("Payout" == message)
ShowPayoutMenu(id);
else if("Bonus" == message)
ShowBonusMenu(id);
else if("Time" == message)
ShowTimerMenu(id);
else
{
integer index = llListFindList(AmountChoices, [ message ]);
if(index >= 0)
{
campadd = (integer)message;
state Running;
}
else
{
index = llListFindList(BonusChoices , [ message ]);
if(index >= 0)
{
campmoney = (integer)message;
state Running;
}
else
{
index = llListFindList(TimerChoices, [ message ]);
if(index >= 0)
{
camptimeM = message;
camptime = 60 * (integer)message; // Payout time in seconds (Script USES this)
state Running;
}
}
}
}
}
}
state Disabled
{
state_entry()
{
llSetText("",<0,1,0>,1); // Set the hovertext to attract mode
}
on_rez(integer t)
{
llResetScript();
}
touch_start(integer total_number)
{
// Owner or owner Group control
key id = llDetectedKey(0);
if( (id == llGetOwner()))
{
state Menu;
}
}
}
Any help is greatly appreciated.
Always,
Corbin
;