list g_DONATORS;
list g_AMOUNTS;
list g_TIMES;
key g_OWNER;
default
{
state_entry()
{
g_OWNER = llGetOwner();
llSetObjectName((string)llKey2Name(g_OWNER) + "'s Tip Jar");
llOwnerSay("Your tip jar is ready to go...");
}
on_rez(integer int)
{
llResetScript();
}
touch_start(integer int)
{
if(llDetectedKey(0) == g_OWNER)
{
integer total = 0;
integer x;
integer Length = llGetListLength(g_DONATORS);
if (Length == 0) llOwnerSay("You have had no donations yet.
Work a little harder!");
else
{
llOwnerSay("Here Are The Stats From Your Tip Jar");
for (x = 0;x < Length;x++)
{
string name = llList2String(g_DONATORS,x);
string amount = llList2String(g_AMOUNTS,x);
string times = llList2String(g_TIMES,x);
total += (integer)amount;
llOwnerSay((string)(x+1) + ". " + name + " - $L " +
amount + " (" + times + " times)");
}
llOwnerSay("Your Total So Far is $L " + (string)total);
}
}
}
money(key giver, integer amount)
{
string name = llKey2Name(giver);
integer Position = llListFindList(g_DONATORS,(list)name);
if (Position == -1)
{
integer times = 1;
g_DONATORS += name;
g_AMOUNTS += amount;
g_TIMES += times;
llInstantMessage(giver,"Thank you for your donation " +
name + ". It is appreciated!");
}
else
{
integer amount = llList2Integer(g_AMOUNTS,Position) +
amount;
integer times = llList2Integer(g_TIMES,Position) + 1;
g_AMOUNTS =
llListReplaceList(g_AMOUNTS,(list)amount,Position,Position);
g_TIMES =
llListReplaceList(g_TIMES,(list)times,Position,Position);
llInstantMessage(giver,"Wow! You have donated " +
(string)times + " times for a total of $L " + (string)amount + "! Thank you!!!");
}
}
}