BIS fnc addStackedEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
m (Text replacement - "\| *((\[\[[a-zA-Z0-9_ :\\\-\/|()]+\]\],? ?)+) * \}\}" to "|seealso= $1 }}")
(formatting and locality)
Line 1: Line 1:
{{RV|type=function
{{RV|type=function


| arma3
|game1= arma3


|1.00
|version1= 1.00


|gr1 = Event Handlers
|gr1 = Event Handlers


| 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, user arguments are appended to the end of <tt>_this</tt> array. Note that if you try to add empty EH, i.e. with empty code, it will simply be ignored.
|eff= local
 
|mp= This command has the same locality as [[addMissionEventHandler]].
 
|descr= 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, user arguments are appended to the end of <tt>_this</tt> array. Note that if you try to add empty EH, i.e. with empty code, it will simply be ignored.
<br><br>
<br><br>
<u>Supported event handlers</u>
<u>Supported event handlers</u>
Line 20: Line 24:
{{Feature|arma3 | Since '''{{arma3}}''' v1.57 a stackable MissionEventHandler is available and should be used instead: [[Arma_3:_Event_Handlers/addMissionEventHandler#MapSingleClick|MapSingleClick]]}}
{{Feature|arma3 | Since '''{{arma3}}''' v1.57 a stackable MissionEventHandler is available and should be used instead: [[Arma_3:_Event_Handlers/addMissionEventHandler#MapSingleClick|MapSingleClick]]}}


| [id, event, code, arguments] call [[BIS_fnc_addStackedEventHandler]];  
|s1= [id, event, code, arguments] call [[BIS_fnc_addStackedEventHandler]];  


|p1= id: [[String]] - custom id, a unique identifier. Adding same type of EH with the same id will overwrite existing
|p1= id: [[String]] - custom id, a unique identifier. Adding same type of EH with the same id will overwrite existing
Line 30: Line 34:
|p4= arguments: [[Array]] of [[Anything]] - arguments to make available in code in <tt>_this</tt> array
|p4= arguments: [[Array]] of [[Anything]] - arguments to make available in code in <tt>_this</tt> array


| [[String]] - custom id on success or "" on failure
|r1= [[String]] - custom id on success or "" on failure
   
   
|x1= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[time]]}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>
|x1= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[time]]}] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>
Line 36: Line 40:
|x2= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[position]] (_this [[select]] 0)}, [<nowiki/>[[player]]]] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>
|x2= <code>["someId", "onEachFrame", {[[hintSilent]] [[str]] [[position]] (_this [[select]] 0)}, [<nowiki/>[[player]]]] [[call]] [[BIS_fnc_addStackedEventHandler]];</code>


|seealso= [[BIS_fnc_removeStackedEventHandler]]
|seealso= [[addMissionEventHandler]] [[BIS_fnc_removeStackedEventHandler]]
}}
}}


Line 55: Line 59:
<!-- Note Section END -->
<!-- Note Section END -->
</dl>
</dl>





Revision as of 10:23, 7 March 2021

Hover & click on the images for description

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, user arguments are appended to the end of _this array. Note that if you try to add empty EH, i.e. with empty code, it will simply be ignored.

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 ([<units>,<pos>,<alt>,<shift>]) and in special variables _units, _pos, _alt, _shift
  • "onPreloadStarted" - no EH params
  • "onPreloadFinished" - no EH params
Arma 3
Since Arma 3 v1.57 a stackable MissionEventHandler is available and should be used instead: MapSingleClick
Execution:
call
Multiplayer:
This command has the same locality as addMissionEventHandler.
Groups:
Event Handlers

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 - custom id on success or "" on failure

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:
addMissionEventHandler 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
Posted on 25 Jun, 2014
ffur2007slx2_5
Arma 3 logo black.png1.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


Posted on January 3, 2019 - 13:52 (UTC)
DrSova
For returning array with all ids: missionNamespace getVariable [format["BIS_stackedEventHandlers_%1",_event],[]]; Where is _event - name of event ('OnEachFrame', etc.)