Taming scriptish

Get Help on scripting in POL with configurations, config setups, script trouble shooting, etc.
Post Reply
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Taming scriptish

Post by Poi »

Ok, so I'm trying to make it so animals never leave masters if they are a staff members...
This is what I have so far:

Code: Select all

  var char;
  var onchars := EnumerateOnlineCharacters();
      char := GetObjProperty(me,"master");
      foreach person in onchars
        if(person.serial == char)
          masterr := person;
          break;
        endif
      endforeach
if(masterr.cmdlevel > 2)
return;
endif
    endif
Do you think this will work?(I don't want to restart the shard and test it, I need to wait for a little while to restart)
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Oh sure, that'll work. If it's in the should-I-run-or-stay-loyal check.

Later on I might comment the code itself to maybe give you couple of hints.
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

Ok, cool thanks
User avatar
ncrsn
Grandmaster Poster
Posts: 255
Joined: Fri Feb 10, 2006 12:15 am

Post by ncrsn »

Instead of restarting the server every now and then, use function Unload_Scripts (http://docs.polserver.com/pol097/single ... e=osem.xml). And if possible (should be!), do test your work on a private server before turning it public - that's of course up to you to decide, but if I'd be a player I'd appreciate it.

If you have a serial of the object you want to work with, don't bother enumerating all the characters, mobiles or items - just use SystemFindObjectBySerial (http://docs.polserver.com/pol097/single ... e=uoem.xml) with required flags - it's clean, it's fast, it's the way to go. If only you are using modern POL, say, 092 or newer.

NPC's have this member master and a method SetMaster. With those you can get rid of the cprop-based system and make your scripts even neatier.

As a summary, I'd suggest you to read through all the existing documentations (http://docs.polserver.com/ - pick your version) - you might learn a useful trick or two!
Poi
Grandmaster Poster
Posts: 298
Joined: Fri Apr 14, 2006 9:36 am

Post by Poi »

By the way, this didn't work =/
Luth
Former Developer
Posts: 200
Joined: Mon Jan 30, 2006 8:10 am

Post by Luth »

Code: Select all

// "master" should have the serial of the owner (who.serial)
var char := GetObjProperty(me,"master");
char := SystemFindObjectBySerial(char, SYSFIND_SEARCH_OFFLINE_MOBILES);
if(char)
  if(char.cmdlevel > 2)
    return 0;
  endif
endif
return 1;
Without comment on whether your script works or not, this may be an easier and faster way of writing it.
Post Reply