Advertisement
kopilo

RLVa - automated group change on tp.

Apr 20th, 2012
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. key r;
  2. integer enabled = 1;
  3. integer l;
  4. integer chan;
  5. string group;
  6. string landGroup;
  7.  
  8. setGroup() {
  9.     if(enabled < 0 ) return;
  10.     string t = (string)llList2Key(llGetParcelDetails(llGetPos(),[PARCEL_DETAILS_GROUP]),0);
  11.     r = llHTTPRequest("http://world.secondlife.com/group/" + t,[],"");
  12. }
  13.  
  14. default
  15. {
  16.     touch_start(integer i) { llResetTime(); }
  17.     touch_end(integer i) {
  18.         if(llGetTime() > 0.3) enabled *= -1;
  19.         if(enabled > 0) llSetColor(<0,6,0>, ALL_SIDES);
  20.         else llSetColor(<6,0,0>, ALL_SIDES);
  21.     }
  22.        
  23.     //group2key -- parse and set
  24.     http_response(key request_id, integer status, list metadata, string body) {
  25.         if(r == request_id) {
  26.             //set group
  27.             landGroup =  llList2String(llParseString2List(body, ["<title>","</title>"], []), 1);
  28.             llOwnerSay("@setgroup:" + landGroup + "=force");
  29.            
  30.             //states active group when it changes between teleports
  31.             chan = (integer)(llFrand(100000) + 100);
  32.             l = llListen(chan, "", llGetOwner(), "");
  33.             llSleep(0.6);
  34.             llOwnerSay("@getgroup=" + (string)chan);
  35.         }
  36.     }
  37.     //post group change checks
  38.     listen(integer c, string n, key a, string m) {
  39.         //check if was able to change to land group;
  40.         if(landGroup != m) { //set to none if so.
  41.             llOwnerSay("@setgroup:none=force"); //on land group fail, set to nothing
  42.         }
  43.         else if(m != group) {
  44.             group = m;
  45.             llOwnerSay("Active group is " + group);
  46.         }
  47.         llListenRemove(l);
  48.     }
  49.    
  50.     changed(integer p) {
  51.         if((p & CHANGED_TELEPORT) || (p & CHANGED_REGION)) setGroup();
  52.     }
  53. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement