PenUltima Online Forum Index Official Core: 096.7
Official Core: 097 2008-02-26
Donate towards the POL web hosting bill!
 POL Home   FAQ   Search    Memberlist   Usergroups    Register    Profile   Log in to check your private messages   Log in
How to pass a parameter to a ControlScript?

 
Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help
Display posts from previous:   

Author Message
timginter



Joined: 22 Apr 2008
Posts: 2

PostPosted: Sat May 03, 2008 12:47 pm    Post subject: How to pass a parameter to a ControlScript? Reply with quote

Hi.
I wrote a script for an item which, when used by a character, creates another item. This created item has a ControlScript and I need to pass the character who used the previous script to that ControlScript. I've tried SetObjProperty(item, "Creator", who); in the first script, and creator := GetObjProperty(item, "Creator"); in the ControlScript, but, when I want to create another item (through the ControlScript) using CreateItemInContainer(creator.backpack, [hex-type], [amount]); it doesn't seem to work :/ I think the method in itself is OK and who isn't correct. I've tried who.serial, but it doesn't seem to work either :/
Any suggestions?

Author Message
Pierce



Joined: 02 Feb 2006
Posts: 259

PostPosted: Sat May 03, 2008 1:01 pm    Post subject: Reply with quote

I would suggest this way.

First script (item creation):

Code:

...
SetObjProperty(item, "Creator", who.serial);
...


Second script (control script):
Code:

...
var createdbyserial := GetObjProperty(item, "Creator");
var creator := SystemFindObjectBySerial(createdbyserial,SYSFIND_SEARCH_OFFLINE_MOBILES);
if(creator)
 ...
endif
...

Author Message
timginter



Joined: 22 Apr 2008
Posts: 2

PostPosted: Sat May 03, 2008 3:10 pm    Post subject: Reply with quote

Thanks a lot, works fine now :)

Author Message
CWO



Joined: 04 Feb 2006
Posts: 713
Location: Chicago, IL USA

PostPosted: Sun May 04, 2008 1:17 am    Post subject: Reply with quote

Yes never set an object reference to a prop. Always set its serial and do SystemFindObjectBySerial.

Post new topic   Reply to topic    PenUltima Online Forum Index -> Scripting Help All times are GMT - 4 Hours
Page 1 of 1

 




Powered by phpBB © 2001, 2005 phpBB Group :: Theme & Graphics by GHS & Scott E. Royalty