CODE
// user defined settings
integer campadd = 5; // Amount to pay each cycle.
integer camptime = 20; // Payout time in minutes.
integer payoutLimit = 15; // Payout Limit in L$ when chair pays camper and boots them off.
vector float_text_color = <1,1,0>; // Floating Text Color. RGB 0.0 - 1.0
// End user defined settings
//---------------------------
//DO NOT Edit below this line unless you know what your doing. You have been warned.
//If you don't know what your doing, and are gunna edit this anyway, make sure to back up the original.
integer x;
integer campmoney = 0;
integer camptimeMin;
string camptimeM;
string reciever;
integer totaltime;
integer clicker;
integer loop = 0;
integer totalPayout;
integer group;
// Menu Settings**
list MenuChoices = ["On","Off","Reset","Payout","Max Pay","Time","Group"];
list AmountChoices = ["1$","2$","3$","4$","5$","10$"];
list MaxChoices = ["10","15","20","25","30","40","50","60","70","80","90","100"];
list TimerChoices = ["1 minute","2 minutes","3 minutes","4 minutes","5 minutes","10 minutes","15 minutes","20 minutes","30 minutes","40 minutes","50 minutes","60 minutes"];
list GroupChoices = ["1","0"];
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);
}
ShowMaxMenu(key id)
{
string text = "Max Pay Menu\nPlease Select an amount";
// finally show the dialog
llDialog(id,text,MaxChoices,listenchannel);
UpdateListen(id);
}
ShowTimerMenu(key id)
{
string text = "Timer Menu\nPlease Select a time period in minutes";
// finally show the dialog
llDialog(id,text,TimerChoices,listenchannel);
UpdateListen(id);
}
ShowGroupMenu(key id)
{
string text = "Group Menu\nTurn on or off Group only access, 1 for yes, 0 for no";
// finally show the dialog
llDialog(id,text,GroupChoices,listenchannel);
UpdateListen(id);
}
SetInactive()
{
reciever = NULL_KEY; // forget who the receiver was
campmoney = 0; // reset earning count to 0
llSetText("Stand for free money, \nL$" + (string)campadd + " every " + camptimeM + "!!\nMax Pay L$" + (string)payoutLimit + "\nGroup only access: ",float_text_color,1); // change hovertext back to attract mode
llSetAlpha(1.0, ALL_SIDES);
llSetTimerEvent(0); // Nobody is sitting on me, so no need to call myself anymore. Disable timer.
}
// **STATES**
default
{
state_entry()
{
camptimeM = (string)camptime;
x = camptime*60;
camptime = x;
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 allow the object to take L$ from you, or the device will NOT work properly!!");
}
}
}
//** 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 off;
else if("Reset" == message)
llResetScript();
else if("Payout" == message)
ShowPayoutMenu(id);
else if("Max Pay" == message)
ShowMaxMenu(id);
else if("Time" == message)
ShowTimerMenu(id);
else if("Group" == message)
ShowGroupMenu(id);
else
{
integer index = llListFindList(AmountChoices, [ message ]);
if(index >= 0)
{
campadd = (integer)message;
llWhisper(0,"Camp rate set to L$" + (string)campadd);
state Running;
}
else
{
index = llListFindList(MaxChoices, [ message ]);
if(index >= 0)
{
payoutLimit = (integer)message;
llWhisper(0,"Max Pay set to L$" + (string)payoutLimit);
state Running;
}
else
{
index = llListFindList(TimerChoices, [ message ]);
if(index >= 0)
{
camptimeM = message;
camptime = 60 * (integer)message; // Payout time in seconds (Script USES this)
llWhisper(0,"Camp Time set to " + (string)camptimeM + "!");
state Running;
}
else
{
index = llListFindList(GroupChoices, [ message ]);
if(index >= 0)
{
group = (integer)message;
llWhisper(0,"Group only access set to " + (string)group + "!");
state Running;
}
}
}
}
}
}
}
//**STATE RUNNING**
state Running
{
state_entry()
{
llSetText("Stand for free money,\nL$" + (string)campadd + " every "+camptimeM+"!!,\nMax Pay L$" + (string)payoutLimit,<0,1,0>,1);
}
touch_start(integer total_number)
{
key id = llDetectedKey(0); // Get the key id of the one touching me
if( (id == llGetOwner())) // if the id of the one touching me IS my owner
{
state Menu; // go to the state called Menu
}
else // its not the owner touching me
{
llWhisper(0,"Right click and choose 'Earn' to make L$" + (string)campadd + " every "+camptimeM+"!!");
}
}
changed(integer change)
{ // something changed
if (change & CHANGED_LINK)
{ // and it was a link change
if (llAvatarOnSitTarget() != NULL_KEY)
{ // and the changed link is an avatar on my sit target
reciever = llAvatarOnSitTarget(); // store the key of the avatar that is sitting on my sit target
llSetText(llKey2Name(reciever) + " has earned: L$"+(string)campmoney,<0,1,0>,1); // Change text to update earnings
llSetTimerEvent(camptime); // amount of time between payments
llSetAlpha(0, ALL_SIDES); // make the object transparent
return; // leave the current function or event.. not sure why this is here, or if its needed.. i think it sends us to timer
}
else
{ // otherwise go back to Inactive Status
llUnSit(llAvatarOnSitTarget());
SetInactive();
}
}
else if (llAvatarOnSitTarget() == NULL_KEY)
{ // if the avatar has gotten up
if (campmoney>0 && loop >= clicker) // not sure about the clicker and loop or &&
{
llGiveMoney(reciever,campmoney); // give the avatar the amount of money he has earned.
SetInactive();
}
else if (campmoney<0)
{
SetInactive();
}
}
}
timer()
{
campmoney = campmoney + campadd;
llSetText(llKey2Name(reciever) + " has earned: L$"+(string)campmoney,<0,1,0>,1);
if (llAvatarOnSitTarget() != NULL_KEY)
{
loop++; // If there's someone sitting on me, Do Nothing, ELSE
}
integer temp = totalPayout + campmoney;
if(temp >= payoutLimit)
{
llWhisper(0, "I'm sorry but you have reached the payout limit");
llUnSit(llAvatarOnSitTarget()); // unsit him or her
}
else if(llAvatarOnSitTarget() == NULL_KEY)
{ // Noone's sitting on me, reset the vars
SetInactive();
}
}
}
//**STATE OFF**
state off
{
state_entry()
{
llWhisper(0, "My owner has asked me to turn off!");
llSetText("Off",<1,0,0>,1);
}
touch_start(integer total_number) // when i'm touched..
{
if (llDetectedKey(0) == llGetOwner()) // it is the owner touching me
{
llWhisper(0,"My owner has asked me to turn on!.");
state Running;
}
else // its not the owner touching me
{
llWhisper(0,"Only the owner can turn this back on");
}
}
}