Page 1 of 1
Taming scriptish
Posted: Wed Jul 09, 2008 8:37 am
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)
Posted: Wed Jul 09, 2008 8:43 am
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.
Posted: Wed Jul 09, 2008 8:55 am
by Poi
Ok, cool thanks
Posted: Wed Jul 09, 2008 11:48 am
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!
Posted: Thu Jul 10, 2008 7:36 am
by Poi
By the way, this didn't work =/
Posted: Thu Jul 10, 2008 11:21 am
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.