Advertisement
Gayngel

Owner Paging System

Jan 16th, 2017
504
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. key Owner;
  2. key Toucher;
  3. string previous_online = "0";
  4. integer lchan = -98;
  5. integer lhandle;
  6. key ReqOwnerStatus;
  7. list Messages;
  8.  
  9. default
  10. {
  11.     on_rez(integer start_param)
  12.     {
  13.      
  14.      llResetScript();  
  15.        
  16.     }
  17.     state_entry()
  18.     {
  19.         Owner = llGetOwner();
  20.         llSetTimerEvent(60.0);
  21.     }
  22.  
  23.     touch_start(integer total_number)
  24.     {
  25.        
  26.         if(previous_online == "0")
  27.         {
  28.            Toucher = llDetectedKey(0);
  29.            llListenRemove(lhandle);
  30.            llListen(lchan, "", Toucher, "" );
  31.            llTextBox(Toucher, "The owner is offline. Please leave a message for them.", lchan);
  32.            
  33.         }
  34.        
  35.         else
  36.         {
  37.            
  38.             llInstantMessage(llDetectedKey(0),"secondlife:///app/agent/"+(string)Owner+"/about" + " is online! Click their name  in this message to open their profile.");
  39.            
  40.         }
  41.        
  42.     }
  43.    
  44.     listen(integer chan, string name, key id, string msg)
  45.     {
  46.        
  47.         if(chan == lchan)
  48.         {
  49.          
  50.          llInstantMessage( Toucher, "You message has been stored and will be delivered to the owner when they are online again.");
  51.          Messages += "secondlife:///app/agent/"+(string)id+"/about"+": "+ msg;  
  52.            
  53.         }
  54.        
  55.     }
  56.    
  57.     timer()
  58.     {
  59.      
  60.     ReqOwnerStatus =  llRequestAgentData(Owner, DATA_ONLINE);  
  61.        
  62.        
  63.     }
  64.    
  65.     dataserver(key RequestId, string data)
  66.     {
  67.         if(RequestId == ReqOwnerStatus)
  68.        
  69.          if(data!=previous_online)
  70.             {
  71.               //  llSay(0,"Changed at "+llGetTimestamp()+"; "+(string)target+" DATA_ONLINE = "+data);
  72.                 if(data == "1")
  73.                 {
  74.                  
  75.                 if(Messages != [])  // If message list is not blank.
  76.                 {
  77.                    
  78.                    integer llength = llGetListLength(Messages);
  79.                    integer i;
  80.                    
  81.                    for(i = 0; i < 0; ++ i)
  82.                    {
  83.                      
  84.                      llInstantMessage(Owner,llList2String(Messages,i));
  85.                        
  86.                    }
  87.                    
  88.                 }
  89.                    
  90.                 }
  91.                
  92.                 else if(data == "0")
  93.                 {
  94.                  
  95.                   // Do nothing if offline.
  96.                    
  97.                 }
  98.                 previous_online=data;
  99.             }        
  100.        
  101.     }
  102.    
  103.    
  104.    
  105. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement