SyntheticLogic

Dialog option to toggle owner only/public

Mar 31st, 2021
350
144 days
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. integer AllowPublic;
  2. integer channel;
  3. integer lis;
  4.  
  5. OptionDialog(key id) {
  6.     channel = 10000 - (integer)llFrand(12345678); // generate a random negative number
  7.     lis = llListen(channel, "", id, ""); // open a listen
  8.     llSetTimerEvent(60); // sett or refresh time untill timer
  9.     llDialog(id, "Select an option:", [CreateButName()], channel); // send an dialog to 'id'
  10. }
  11.  
  12. // create dialog button
  13. string CreateButName() {
  14.     if(AllowPublic) return "Owner only";
  15.     return "Public";
  16. }
  17.  
  18. default {
  19.  
  20.     listen(integer ch, string name, key id, string msg) {
  21.         if(msg == "Owner only" || msg == "Public") { // should i change value for 'allowpublic'
  22.             if(id == llGetOwner()) { //  im only accepting command from owner
  23.                 AllowPublic = !AllowPublic; // set it to it's opposite
  24.             }
  25.         }
  26.         else {
  27.             // you're code goes here
  28.         }
  29.     }
  30.  
  31.     touch_start(integer ts) {
  32.         key id = llDetectedKey(0);
  33.         if(id == llGetOwner()) OptionDialog(id); // allways work for owner
  34.         else if(AllowPublic) OptionDialog(id); // word for othes if 'allowpublic' is true
  35.         else llRegionSayTo(id, 0, "Im not set to public"); // say this if 'allowpublic' is false
  36.     }
  37.  
  38.     timer() {
  39.         llSetTimerEvent(0); // stop repeating timer
  40.         llListenRemove(lis); // remove listen
  41.     }
  42.  
  43. }
RAW Paste Data

Adblocker detected! Please consider disabling it...

We've detected AdBlock Plus or some other adblocking software preventing Pastebin.com from fully loading.

We don't have any obnoxious sound, or popup ads, we actively block these annoying types of ads!

Please add Pastebin.com to your ad blocker whitelist or disable your adblocking software.

×