It is currently Fri Nov 21, 2008 7:50 pm

All times are UTC - 8 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Taming scriptish
PostPosted: Wed Jul 09, 2008 8:37 am 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
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:
  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)


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 8:43 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 225
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.


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 8:55 am 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
Ok, cool thanks


Top
 Profile  
 
 Post subject:
PostPosted: Wed Jul 09, 2008 11:48 am 
Offline
User avatar

Joined: Fri Feb 10, 2006 12:15 am
Posts: 225
Instead of restarting the server every now and then, use function Unload_Scripts (http://docs.polserver.com/pol097/singlefunc.php?funcname=Unload_Scripts&xmlfile=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/singlefunc.php?funcname=SystemFindObjectBySerial&xmlfile=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!


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 10, 2008 7:36 am 
Offline

Joined: Fri Apr 14, 2006 9:36 am
Posts: 240
By the way, this didn't work =/


Top
 Profile  
 
 Post subject:
PostPosted: Thu Jul 10, 2008 11:21 am 
Offline
POL Developer

Joined: Mon Jan 30, 2006 8:10 am
Posts: 147
Code:
// "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.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC - 8 hours


Who is online

Users browsing this forum: No registered users and 0 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
Style based on FI Subice by phpBBservice.nl