User:Toady Nakamura/Simple Recording Tipjar

From Second Life Wiki
Revision as of 17:53, 18 May 2012 by Toady Nakamura (talk | contribs) (added a couple nifty functions)
Jump to navigation Jump to search
  • Put this script in any object you own for an instant tipjar.
  • By Toady Nakamura

<lsl> integer totaldonated;

default {

   on_rez( integer sparam )
   {
       llResetScript(); // reset when rezzed out
   }
   state_entry()
   {
       llSetText("Donation Box\nL$0 Donated so far",<1.0,1.0,1.0>,0.85);
       // set text, "message", color vector (here white), and intensity (here 85%)
   }
   money(key id, integer amount)// When someone pays the system records their key & the amount
   {
       totaldonated = totaldonated + amount;
       // add the amount just given to the total from before
       // "amount" comes from the money event
       llSetText("Donation Box \n L$" + (string)totaldonated + " Donated so far",<1.0,1.0,1.0>,0.85);
       // set the text to show the gift
       llInstantMessage(id,"Thank you for the donation!, " + llKey2Name(id));
       // send a private thank you to giver.
       // "id" comes from the money event
       llInstantMessage(llGetOwner(), llKey2Name(id) + " just donated $L" + (string)amount);
       // privately message owner to say how much the donation was and the name of the giver.
   }

} </lsl>