Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Discussion: Auto die tip jar

grumble Loudon
A Little bit a lion
Join date: 30 Nov 2005
Posts: 612
06-21-2006 18:48
I've found people leaving tip jars at clubs and it's a hassle to keep cleaning them up.
This script adds less sim loading than the popular 3 script tip jar since each script adds sim load.

This script is designed to be used in the one prim tip jar, however it can be used in more complex ones.

The big differance is that the script dies if you are not in the sim.

CODE

//Free open soure Auto die tip jar by grumble Loudon and LaserFur Leonov
//Released into the public domain, no rights reserved.
//
//Created after vewing scripts from Keknehv Psaltery, jean cook, ama omega, nada epoch, YadNi Monde
//
//********************************************************
string m_ownerName;
key m_ownerKey;

integer m_money;
integer m_DieTimer;

//set the floating text,
SetText(string PayeText){
string Text;
Text = m_ownerName + "'s Tip Jar.\n$";
Text += (string)m_money + "L Donated so far\n";
if (llStringLength(PayeText) >= 0){
Text += PayeText;
};
llSetText(Text,<0,0,1>,1);
}//set Text
//********************************************************
default
{
state_entry()
{
llSetStatus(STATUS_BLOCK_GRAB, TRUE);
m_ownerKey = llGetOwner();
m_ownerName = llKey2Name(m_ownerKey);

SetText("");
// llTargetOmega(<0,0,0.075>,PI,0.05); //rotate if desired
llSetTimerEvent(53); //use odd numbers to prevent all scripts in sim from triggering at the same time
}
//*********************************************************8
on_rez(integer RezNumber){
llResetScript();
}
//*********************************************************
money(key id, integer amount)
{
m_money += amount;
SetText("$" + (string)amount + "L Was donated by "+(string)llKey2Name(id)+" last.");

llInstantMessage(id,"Thanks for the tip. :)");
llInstantMessage(m_ownerKey,(string)llKey2Name(id)+" payed $" + (string)amount + "L");
}//money
//*********************************************************
timer()
{
if (llKey2Name(m_ownerKey) == ""){ //he's not in this sim
m_DieTimer++;
if (m_DieTimer > 2 ) { //give him some time, just in case he crashed.
llDie();//he hasn't came back yet
};//
}else{
m_DieTimer =0; //he's back
};//in sim
}//timer
//*********************************************************
}//default
Nada Epoch
The Librarian
Join date: 4 Nov 2002
Posts: 1,423
Original Thread
06-28-2006 08:30
/15/31/115584/1.html
_____________________
i've got nothing. ;)
Jesse Malthus
OMG HAX!
Join date: 21 Apr 2006
Posts: 649
06-28-2006 15:15
Interesting use of llKey2Name, I like it!
Travis Lambert
White dog, red collar
Join date: 3 Jun 2004
Posts: 2,819
07-05-2006 12:45
Just a tip:

llKey2Name can produce some unpredictable results immediately after an agent leaves a sim - especially if the agent has simply crossed to an adjacent sim.

While using llKey2Name to detect agent presence in the sim is probably fine for this tip jar script, I prefer the method below for better accuracy if you need to know immediately that the agent has left the sim:

CODE
if (llGetAgentInfo(m_ownerKey) == 0)
{
//m_ownerKey is not in the sim
}
_____________________
------------------
The Shelter

The Shelter is a non-profit recreation center for new residents, and supporters of new residents. Our goal is to provide a positive & supportive social environment for those looking for one in our overwhelming world.
Gordon Wendt
404 - User not found
Join date: 10 May 2006
Posts: 1,024
07-07-2006 23:52
A way to get rid of the issue of the glitchiness coudl also be to just set it to check every x seconds (say 180) and that way you would be less likely to run into the owner just leaving the sim issues.