Writing a custom script that responds to a tip event

With the Techno Tip Cube, you can drop in your own script -- into any prim (root prim or otherwise) -- that can perform a custom action when someone tips into the cube. When a tip is made, the Techno Tip Cube will broadcast a linked message #8000 to all prims in the linked set. The message string is a comma-separated list of three fields:

"<tip amount>, <avatar key>, <avatar name>"

Obviously, the possibilities on what your script can do are unlimited! The following is a very simple example.

// =================================================================================
// TECHNO TIP CUBE - CUSTOM SCRIPT
// -------------------------------
// This script can be placed in any Techno Tip Cube prim (root prim or otherwise).
// The example script that follows illustrates how to respond to a tip notify message.
//
// In this example, we will hand out objects that YOU have dropped into the
// Techno Tip Cube contents pane.  Be sure that the objects are copyable and
// transferrable, otherwise you will receive a script error.
// =================================================================================

integer MSGNUM_TIP_RECEIVED  = 8000;

// The following are names of copyable/transferrable items in your
// cube's inventory that you would like handed out to tippers.
string ITEM_NAME_1 = "item name goes here";
string ITEM_NAME_2 = "item name goes here";

default {

  link_message( integer sender_num, integer num, string str, key id ) {
  // Learn more about this function at http://wiki.secondlife.com/wiki/Link_message

    if ( num == MSGNUM_TIP_RECEIVED ) {
         // The Techno Tip Cube has received a tip.  Let's perform a custom response
         // to this action.  Here, we will give the tipper one item if the tip amount
         // is 100L or higher, or another item if the tip amount is at least 10L.
         // If the tip amount is under 10L, then nothing is given.

         // Parse the message string to obtain all the information on this tipper.
         list tipInfo = llCSV2List( str );

         // Transfer the parts to individual variables.
         integer amount = llList2Integer( tipInfo, 0 );
         key avatarKey = llList2Key( tipInfo, 1 );
         string name = llList2String( tipInfo, 2 );

         // Process the information!
         if ( amount >= 100 )
           llGiveInventory( avatarKey, ITEM_NAME_1 );
         else if ( amount >= 10 )
           llGiveInventory( avatarKey, ITEM_NAME_2 );
         }
   }
}

Home | Intro | Overview | Notecards | Updating | Sales | TipTracer | Login

ZappoWappy™ (c) 2006-2021