OFPEC Forum
Editors Depot - Mission Editing and Scripting => OFP - Editing/Scripting General => Topic started by: DucusSumus on 17 May 2003, 23:29:50
-
I have learned quite a bit about editing since I started, but there is one thing I still no nothing about... something I have seen in quite a few script snippets: addEventHandler and removeAllEventHandlers. What are event handlers? What does any of this mean? Can anyone help me out here?
Thanks,
DucusSumus
-
object addEventHandler handler
Operand types:
object: Object
handler: Array
Compatibility:
Version 1.85 required.
Type of returned value:
Number
Description:
Format of handler is [type,command]. Check scripting topic Event handlers for more information. Index of currently added handler is returned.
Example:
player addEventHandler ["killed",{_this exec "playerKilled.sqs"}]
Here ya go m8
-
Right, I have read that from the command ref., but I still have absolutely no idea what they are, or what they're purpose is... can anyone give an explanation?
Thanks,
DucusSumus
-
Yeah, this is a custom event that you can make happen...
I'm not sure on what the 'type' means in:
player addEventHandler [type,command]
but the command is just a reference to a script you've made, so whenever the 'type' is envoked your custom script plays...
Not sure, but you might be able to use it to map keys like say if you press the 'I' button it would play your script.
An event handler just catches certain events and then you can tell it what to do with them - so based on the ref example when a player is killed a "killed" notification/event is sent out and that can be captured and act as a trigger for something.
-
Use the forum search function, you'll pick up a few tips.
Event handlers launch a command or script when an event happens.
Events include (I think) killed, hit, fired and probably others. So you can call a script when any of these happens to the loon to whom the eventhandler has been added.
-
Didn't mind to start a new thread on this q, does concern only a few addons that might use eventHandlers for an effect.
Has anyone managed to get the "fired" eventhandler to work with NP2s radio (sebprc25) or BAS delta&ranger packs radio (bas_satcom)?
I once thought this was possible, but nothing happens when you "click the tangent" IE fire, except the static noise. Shame, would've been useful.. I tried it simply with adding a "fired" eventhandler to a unit, and when he uses the weapon above, he gets some actions. I know I got it working, only the script doesn't seem to go off with them radios.