Give Contents only to Newbies by ZenMondo Wormser

From ZenMondo Wormser, 10 Months ago, written in Linden Scripting, viewed 242 times.
URL http://flynnos.org/flynnbin/view/24dfd1d2 Embed
Download Paste or View Raw
  1. //////////////////////
  2. //Give Contents only to Newbies by ZenMondo Wormser
  3. //
  4. // Just place in a prim, along with the inventory items to be given.
  5. // To retrieve the inventory, have a newbie touch the prim.
  6. //
  7. // Contents will be given in a folder named what you want by changing
  8. // a line below only to avatars younger than newb_age which you can change below.
  9. //
  10. //////////////////////
  11.  
  12. // Change "A gift to get you started"  to the name of the folder you want the object to give.(keep the quotes)
  13. string folder_name = "A gift to get you started";
  14.  
  15. //Change age to number of days old
  16. integer newb_age = 30;
  17.  
  18. key age_query;
  19. key avatar_key;
  20.  
  21.  
  22. integer date2days(string data)
  23. {
  24.     integer result;
  25.     list parse_date = llParseString2List(data, ["-"], []);
  26.     integer year = llList2Integer(parse_date, 0);
  27.  
  28.     result = (year - 2000) * 365; // Bias Number to year 2000 (SL Avatars Born After Date)
  29.     list days = [ 0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334 ];
  30.  
  31.     result += llList2Integer(days, (llList2Integer(parse_date, 1) - 1));
  32.     if (year/4 == llRound(year/4)) result += 1;
  33.     result += llList2Integer(parse_date, 2);
  34.  
  35.     return result;
  36. }
  37.  
  38.  
  39.  
  40. //Function to give contents.
  41. giveContents(key avatar)
  42. {
  43.         integer counter = 0;
  44.         integer inventory_num = llGetInventoryNumber(INVENTORY_ALL);
  45.        
  46.         list inventory_list;
  47.        
  48.         while(counter < inventory_num)
  49.         {
  50.             inventory_list = (inventory_list=[]) + inventory_list + llGetInventoryName(INVENTORY_ALL, counter);
  51.             counter ++;
  52.         }
  53.        
  54.         list scriptname = [llGetScriptName()];
  55.        
  56.         integer index = llListFindList(inventory_list, scriptname);
  57.        
  58.         inventory_list = llDeleteSubList(inventory_list, index, index);
  59.        
  60.        
  61.         llGiveInventoryList(avatar, folder_name, inventory_list);
  62.        
  63.        
  64.        
  65.     }
  66.  
  67.  
  68. {
  69.    
  70.  
  71.     touch_start(integer total_number)
  72.     {
  73.         avatar_key = llDetectedKey(0);
  74.         age_query = llRequestAgentData(llDetectedKey(0), DATA_BORN);
  75.     }
  76.    
  77.     dataserver(key queryid, string data)
  78.     {
  79.         if(queryid == age_query)
  80.         {
  81.             string born_on = data;  //Get the Date Avatar was born
  82.             string today = llGetDate();
  83.            
  84.             integer born_on_day =  date2days(born_on);
  85.             integer today_day = date2days(today);
  86.            
  87.             integer total_days_old = today_day - born_on_day;
  88.                            
  89.        
  90.             if(total_days_old > newb_age)
  91.             {  
  92.                 llSay(0, "I am sorry, these items are for avatars are " + (string) newb_age + " days old or younger.  You are " + (string) total_days_old + " days old.");
  93.             }
  94.        
  95.             else
  96.             {
  97.                 giveContents(avatar_key);  
  98.             }
  99.                  
  100.         }  
  101.     }  
  102.    
  103. }
  104.  

Reply to "Give Contents only to Newbies by ZenMondo Wormser"

Here you can reply to the paste above

captcha