Give One Object Per Person (no copy Object version

From ZenMondo Wormser, 6 Months ago, written in Linden Scripting, viewed 123 times.
URL http://flynnos.org/flynnbin/view/c5b42755 Embed
Download Paste or View Raw
  1. list users;
  2. integer objectCount;
  3.  
  4. {
  5.     state_entry()
  6.     {
  7.         objectCount = llGetInventoryNumber(INVENTORY_OBJECT);
  8.         llSetText((string) objectCount + " items remaining", <0,1,0>, 1.0);
  9.     }
  10.  
  11.     touch_start(integer total_number)
  12.     {
  13.         if(objectCount > 0)
  14.         {
  15.             string name = llDetectedName(0);
  16.             if(llListFindList(users, [name]) == -1)
  17.             {
  18.                 users = (users=[]) + users + name; //Add name to list
  19.        
  20.                 llGiveInventory(llDetectedKey(0), llGetInventoryName(INVENTORY_OBJECT, llFloor( llFrand((float) llGetInventoryNumber(INVENTORY_OBJECT))))); //This confusing bit gives a random object from inventory
  21.              
  22.                 objectCount = llGetInventoryNumber(INVENTORY_OBJECT);
  23.                
  24.                 if(objectCount > 0)
  25.                 {
  26.                     llSetText((string) objectCount + " items remaining", <0,1,0>, 1.0);
  27.                 }
  28.                
  29.                 else
  30.                 {
  31.                     llInstantMessage(llGetOwner(), llGetObjectName() + " is empty");
  32.                     llSetText((string) objectCount + " items remaining", <1,0,0>, 1.0);
  33.                 }
  34.             }
  35.            
  36.             else
  37.             {
  38.                  llInstantMessage(llDetectedKey(0), "I am sorry but you have already received your free item. Save some for other people.");  
  39.             }
  40.         }        
  41.     }
  42.  
  43.     changed(integer change)
  44.     {
  45.         if(change & CHANGED_INVENTORY)
  46.         {
  47.             //This is not redundent. llGiveInventory does NOT trigger the changed event these two lines will allow the hovertext to change when ADDING objects
  48.             objectCount = llGetInventoryNumber(INVENTORY_OBJECT);
  49.             llSetText((string) objectCount + " items remaining", <0,1,0>, 1.0);
  50.         }  
  51.     }
  52. }
  53.  

Reply to "Give One Object Per Person (no copy Object version"

Here you can reply to the paste above

captcha