BIS fnc addStackedEventHandler: Difference between revisions
Jump to navigation
Jump to search
m (links) |
Killzone Kid (talk | contribs) (description updated, irrelevant notes removed) |
||
Line 7: | Line 7: | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| | | Stacks an event handler. All event handlers accept user arguments, which are passed to the EH code in <tt>_this</tt> variable. If the EH has own params returned in <tt>_this</tt> variable as well, use arguments are appended to the end of <tt>_this</tt> array. | ||
* "[[onEachFrame]]" | <br><br> | ||
* "[[onPlayerConnected]]" | <u>Supported event handlers</u> | ||
* "[[onPlayerDisconnected]]" | <br><br> | ||
* "[[onMapSingleClick]]" | * <tt>"[[onEachFrame]]"</tt> - no EH params | ||
* "[[onPreloadStarted]]" | * <tt>"[[onPlayerConnected]]"</tt> - EH params are passed as array in <tt>_this</tt> (<tt>[<id>,<uid>,<name>,<jip>,<owner>]</tt>) and in special variables <tt>_id</tt>, <tt>_uid</tt>, <tt>_name</tt>, <tt>_jip</tt>, <tt>_owner</tt> | ||
* "[[onPreloadFinished]]" |= Description | * <tt>"[[onPlayerDisconnected]]"</tt> - EH params are passed as array in <tt>_this</tt> (<tt>[<id>,<uid>,<name>,<jip>,<owner>]</tt>) and in special variables <tt>_id</tt>, <tt>_uid</tt>, <tt>_name</tt>, <tt>_jip</tt>, <tt>_owner</tt> | ||
* <tt>"[[onMapSingleClick]]"</tt> - EH params are passed as array in <tt>_this</tt> (<tt>[<id>,<uid>,<name>,<jip>,<owner>]</tt>) and in special variables <tt>_id</tt>, <tt>_uid</tt>, <tt>_name</tt>, <tt>_jip</tt>, <tt>_owner</tt> | |||
* <tt>"[[onPreloadStarted]]"</tt> - no EH params | |||
* <tt>"[[onPreloadFinished]]"</tt> - no EH params|= Description | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
| [ | | [id, event, code, arguments] call [[BIS_fnc_addStackedEventHandler]]; |= Syntax | ||
|p1= | |p1= id: [[String]] - custom id, a unique identifier. Adding same type of EH with the same id will overwrite existing|= Parameter 1 | ||
|p2= event: [[String]] - event handler | |p2= event: [[String]] - event handler name, see description for supported EHs|= Parameter 2 | ||
|p3= code: [[String]] | |p3= code: [[Code]] or [[String]]. The [[String]] is treated as function name |= Parameter 3 | ||
|p4= arguments: [[Anything]] - arguments to make available in code|= Parameter 4 | |p4= arguments: [[Array]] of [[Anything]] - arguments to make available in code in <tt>_this</tt> array|= Parameter 4 | ||
| [[String]] |= Return value | | [[String]] |= Return value | ||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
|x1= <code>["someId", "onEachFrame", { | |x1= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[time]]}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code> |= | ||
}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code> |= | |||
|x2= <code>["someId", "onEachFrame", { | |x2= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[position]] (_this [[select]] 0)}, <nowiki>[</nowiki>[[player]]]] [[call]] [[BIS_fnc_addStackedEventHandler]];</code> |= | ||
}, | |||
____________________________________________________________________________________________ | ____________________________________________________________________________________________ | ||
Line 45: | Line 44: | ||
<dl class="command_description"> | <dl class="command_description"> | ||
<!-- Note Section BEGIN --> | <!-- Note Section BEGIN --> | ||
<dd class="notedate">Posted on 25 Jun, 2014 | <dd class="notedate">Posted on 25 Jun, 2014 | ||
Line 72: | Line 65: | ||
[[Category:Functions|{{uc:addStackedEventHandler}}]] | [[Category:Functions|{{uc:addStackedEventHandler}}]] | ||
[[Category:{{Name|arma3}}: Functions|{{uc:addStackedEventHandler}}]] | [[Category:{{Name|arma3}}: Functions|{{uc:addStackedEventHandler}}]] | ||
Revision as of 11:57, 15 July 2017
Description
- Description:
- Stacks an event handler. All event handlers accept user arguments, which are passed to the EH code in _this variable. If the EH has own params returned in _this variable as well, use arguments are appended to the end of _this array.
Supported event handlers
- "onEachFrame" - no EH params
- "onPlayerConnected" - EH params are passed as array in _this ([<id>,<uid>,<name>,<jip>,<owner>]) and in special variables _id, _uid, _name, _jip, _owner
- "onPlayerDisconnected" - EH params are passed as array in _this ([<id>,<uid>,<name>,<jip>,<owner>]) and in special variables _id, _uid, _name, _jip, _owner
- "onMapSingleClick" - EH params are passed as array in _this ([<id>,<uid>,<name>,<jip>,<owner>]) and in special variables _id, _uid, _name, _jip, _owner
- "onPreloadStarted" - no EH params
- "onPreloadFinished" - no EH params
- Execution:
- call
- Groups:
- Uncategorised
Syntax
- Syntax:
- [id, event, code, arguments] call BIS_fnc_addStackedEventHandler;
- Parameters:
- id: String - custom id, a unique identifier. Adding same type of EH with the same id will overwrite existing
- event: String - event handler name, see description for supported EHs
- code: Code or String. The String is treated as function name
- arguments: Array of Anything - arguments to make available in code in _this array
- Return Value:
- String
Examples
- Example 1:
["someId", "onEachFrame", {hintSilent str time}] call BIS_fnc_addStackedEventHandler;
- Example 2:
["someId", "onEachFrame", {hintSilent str position (_this select 0)}, [player]] call BIS_fnc_addStackedEventHandler;
Additional Information
- See also:
- BIS_fnc_removeStackedEventHandler
Notes
-
Report bugs on the Feedback Tracker and/or discuss them on the Arma Discord or on the Forums.
Only post proven facts here! Add Note
Notes
- Posted on 25 Jun, 2014
- ffur2007slx2_5
-
(ArmA3 1.22) Stack all codes into one PFH will be less demanding than separated calling within multiple PFH. E.g.
{ [(format [“%1”,_forEachIndex]),”onEachFrame”,_code,[_x]] call BIS_fnc_addStackedEventHandler; } forEach [var0…var100]; //pretty demanding
[_id, ”onEachFrame”,{ {_x call _code} forEach [var0…var100]; }] call BIS_fnc_addStackedEventHandler; //faster