Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Library: Tip jar script

Sleepy Xue
I script Pretty HUDs
Join date: 22 Jun 2008
Posts: 57
12-24-2008 21:08
Ok. I made an OS tip jar script. To use it:
1)Copy the script
2)Put the script in an object
3)Put a notecard in the object; the notecard should be named ''config'' (no quotes)
4)On each line of the notecard, put an agents key. Those avatars will receive the tips
__

CODE

//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////// SCRIPTED BY SLEEPY XUE ////////////////////////
//////////////////////// THIS SCRIPT IS FREE!!! ////////////////////////
//////////////////////// DO NOT SELL!!!!!!!!!!! ////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////
getLine() {
gLine = llGetNotecardLine("config",gNum);
gNum += 1;
}
giveExtra(integer amount) {
while(amount) {
llGiveMoney(llList2String(gPeople,gX),1);
amount -= 1;
gX += 1;
}
gX = 0;
}
split(integer amount) {
gAmount = (amount / gListLength);
gX = gListLength;
amount = 0; //Why not reuse it?
//I would otherwise have to initialize a whole new integer -Save memory =p
while(gX) {
llGiveMoney(llList2String(gPeople,amount),gAmount);
amount += 1;
gX -= 1; //Ends up at 0
}
}
key gLine;
integer gX; //My temp
integer gNum;
integer gListen;
integer gListLength;
integer gAmount; //My temp money holder
integer gStatus = TRUE;
list gPeople;

default {

changed(integer c) {
if(c & CHANGED_INVENTORY)
llResetScript();
}

on_rez(integer param) {
llResetScript();
}

state_entry() {
llRequestPermissions(llGetOwner(),PERMISSION_DEBIT);
}

dataserver(key queryid, string data) {
if(queryid == gLine) {
if(data != EOF) {
gPeople += data;
getLine();
}
else
gListLength = llGetListLength(gPeople);
}
}

run_time_permissions(integer p) {
if(p & PERMISSION_DEBIT) {
llSetText("Tip jar", <255.0,255.0,255.0> ,1.0);
llSetPayPrice(25, [25, 50, 75, 100]);
getLine();
}
}

touch_start(integer num_detected) {
if(llDetectedKey(0) == llGetOwner() && gStatus == TRUE) {
gListen = llListen(31562,"",llGetOwner(),"");
llDialog(llGetOwner(),"Would you like to shut down the tip jar?",["Yes","No"],31562);
llSetTimerEvent(60.0);
}
else if(llDetectedKey(0) == llGetOwner() && gStatus == FALSE) {
gListen = llListen(31562,"",llGetOwner(),"");
llDialog(llGetOwner(),"Would you like to start up the tip jar?",["Yes","No"],31562);
llSetTimerEvent(60.0);
}
}

timer() {
llOwnerSay("The message has timed out. Please click the tip jar again. Thank you =]");
llListenRemove(gListen);
}

listen(integer channel, string name, key id, string message) {
llListenRemove(gListen);
if(message == "Yes" && gStatus == TRUE) {
llSetPayPrice(PAY_HIDE,[PAY_HIDE]);
llSetText("Tip jar is unactive",<255.0,255.0,255.0>,1.0);
gStatus = FALSE;
llSetTimerEvent(0);
}
else if(message == "Yes" && gStatus == FALSE) {
llSetPayPrice(25, [25, 50, 75, 100]);
llSetText("Tip jar",<255.0,255.0,255.0>,1.0);
gStatus = TRUE;
llSetTimerEvent(0);
}
else
llSetTimerEvent(0);
}

money(key id, integer amount) {
if(amount > gListLength && gListLength > 1) {
gAmount = amount % gListLength;
amount -= gAmount;
giveExtra(gAmount);
split(amount);
}
else if(gListLength == 1) {
llGiveMoney(llList2String(gPeople,0),amount);
llSay(0,"Thank you " + llKey2Name(id) + " for your very generous donation.");
return;
}
else if(amount <= gListLength)
giveExtra(amount);
llSay(0,"Thank you " + llKey2Name(id) + " for your very generous donation.");
//llInstantMessage works too =p
}
}


OK! I tested. It all works!
_____________________
I script pretty HUDs.
Sleepy Xue
I script Pretty HUDs
Join date: 22 Jun 2008
Posts: 57
12-25-2008 00:22
For those of you who would like this delivered to you inworld:

http://www.xstreetsl.com/modules.php?name=Marketplace&file=item&ItemID=1095211

Don't worry. It's still free XD
_____________________
I script pretty HUDs.