Adding generic player events ?

Forum where anything UOX3-related goes - including, but not limited to: newbie-support, ideas, general questions, comments, etc and-so-forth.
Post Reply
xantier
UOX3 Novice
Posts: 58
Joined: Tue Dec 20, 2011 6:51 am
Has thanked: 0
Been thanked: 0

Adding generic player events ?

Post by xantier »

As you know i have to attach every script to object to make it work. But how can i attach a script that contains events for ALL players ? For example onSpeech for all players: when i say "om om om", i will fly onto spirituality shrine or a special word that does something else. Can i add events on all players ?
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Yep! You can create a "global" script (for all objects - whether characters or items) by giving it scriptID 0 in jse_fileassociations.scp. Any events in that file will run (if appropriate) for all objects on your shard. To avoid this script becoming to large to maintain, it might be an idea to use TriggerEvent to trigger other, larger script-files from the events in the global one.
-= Ho Eyo He Hum =-
xantier
UOX3 Novice
Posts: 58
Joined: Tue Dec 20, 2011 6:51 am
Has thanked: 0
Been thanked: 0

Post by xantier »

Xuri wrote:Yep! You can create a "global" script (for all objects - whether characters or items) by giving it scriptID 0 in jse_fileassociations.scp. Any events in that file will run (if appropriate) for all objects on your shard. To avoid this script becoming to large to maintain, it might be an idea to use TriggerEvent to trigger other, larger script-files from the events in the global one.
thanks! :)
will it work even on objects with another script ? i mean:
can i attach multiple scripts to an object ? for example, player uses generic event: script ID 0, and when he wears a cloak, it will give him damage resistance, script ID 1.
User avatar
Xuri
Site Admin
Posts: 3704
Joined: Mon Jun 02, 2003 9:11 am
Location: Norway
Has thanked: 48 times
Been thanked: 8 times
Contact:

Post by Xuri »

Hey, sorry for the slow reply.

The global-script (ID 0) should be usable alongside other scripts attached to objects - though only one such other unique script can be attached to each object, so your example of generic event script (global) versus a unique one should work. I'm not sure which script will run (global vs unique) in cases where the same event is present in both scripts, though.
-= Ho Eyo He Hum =-
xantier
UOX3 Novice
Posts: 58
Joined: Tue Dec 20, 2011 6:51 am
Has thanked: 0
Been thanked: 0

Post by xantier »

Xuri wrote:Hey, sorry for the slow reply.

The global-script (ID 0) should be usable alongside other scripts attached to objects - though only one such other unique script can be attached to each object, so your example of generic event script (global) versus a unique one should work. I'm not sure which script will run (global vs unique) in cases where the same event is present in both scripts, though.

i think i will change scriptTrig thing in sources and add script triggers on a BaseObj as a vector<> and add JS functions like attachscript() detach().
Post Reply