Welcome to the Second Life Forums Archive

These forums are CLOSED. Please visit the new forums HERE

Need help with tip jar script

Suki Hirano
冬の温暖
Join date: 30 May 2008
Posts: 172
01-11-2010 19:45
Hello,
Is there any way to prevent a tip jar's script from resetting after it's taken back to the inventory, and re-rezzed? For example, I have a tip jar that will display the total amount of tips given to the owner so far, as well as the amount of the last donation. But if I re-rez the tip jar, both values will go back to L$0.
This is the script:

integer totaldonated;
string owner;

default
{
on_rez( integer sparam )
{
llResetScript();
}
state_entry()
{
owner = llKey2Name( llGetOwner() );
llSetText( owner + "'s Tip Jar.\n$L0 Donated so far",<.25,1,.65>,1);
}

money(key id, integer amount)
{
totaldonated += amount;
llSetText( owner + "'s Tip Jar!\n$L" + (string)amount + " Was donated last!\n" + "$L" + (string)totaldonated + " Donated so far",<.25,1,.65>,1);
llInstantMessage(id,"Thank You for the tip!";);
llInstantMessage(llGetOwner(),(string)llKey2Name(id)+" donated $" + (string)amount);
}
}

Thanks.
_____________________
空想の旋律
Sindy Tsure
Will script for shoes
Join date: 18 Sep 2006
Posts: 4,103
01-11-2010 20:13
This bit here...
From: Suki Hirano

on_rez( integer sparam )
{
llResetScript();
}


...tells it to reset when you rez it. If you take that out, it won't reset.

What you probably want to do is add this, which will just reset it if you give a copy to somebody else...

changed (integer mask)
{
if (mask & CHANGED_OWNER)
{
llResetScript();
}
}
_____________________
Sick of sims locking up every time somebody TPs in? Vote for SVC-3895!!!
- Go here: https://jira.secondlife.com/browse/SVC-3895
- If you see "if you were logged in.." on the left, click it and log in
- Click the "Vote for it" link on the left
Raster Teazle
Registered User
Join date: 13 Sep 2005
Posts: 114
01-11-2010 20:33
Or you can save the total in the objects description field and get it back when rezzing.

llSetObjectDesc( (string)totaldonated ); // save total

totaldonated = (integer)llGetObjectDesc(); // get back total

To reset the total you could manually set the discription to blank or 0.

--------------------------

They could also force a reset if you are using Sindy's modification by opening the script window and clicking the "Reset" button at lower right.
Suki Hirano
冬の温暖
Join date: 30 May 2008
Posts: 172
01-12-2010 18:02
Perfect, thank you. ~~
_____________________
空想の旋律