BIS fnc addScriptedEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(some of the names)
m (Text replacement - "(\|[pr][0-9]+ *= *[^- ]*) *- *T([a-z ])" to "$1 - t$2")
 
(35 intermediate revisions by 6 users not shown)
Line 1: Line 1:
{{RV|type=function


{{Function|= Comments
|game1= arma3
____________________________________________________________________________________________
|version1= 1.00


| arma3 |= Game name
|gr1= Event Handlers


|1.00|= Game version
|descr= Adds a Scripted Event Handler and returns its ID. Additionally, the "ScriptedEventHandlerAdded" Scripted EH is called. For the full list of all available Scripted EHs see [[Arma 3: Scripted Event Handlers]].
____________________________________________________________________________________________


| Adds scripted event handler and returns id. "ScriptedEventHandlerAdded" scripted EH is called. Some of the Scripted EH names used in various scripts and modules:
|s1= [namespace, name, code] call [[BIS_fnc_addScriptedEventHandler]]
* arsenalClosed
* arsenalOpened
* BIS_fnc_playVideo_stopped
* bis_groundSupport_groupSpawned
* curatorObjectPlaced
* curatorObjectRemoteControlled
* curatorUnitAssigned
* dominantSideChanged
* EGSpectator_OnCameraModeChanged
* EndGame_Ended
* EndGame_OnObjectiveCompleted
* EndGame_OnObjectiveEnded
* EndGame_OnObjectiveStateChanged
* EndGame_OnStageChanged
* EndGame_OnStartGameObjectiveCompleted
* garageClosed
* garageOpened
* intelObjectFound
* ownerChanged
* respawn
* respawnTicketsExhausted
* RscDisplayEGSpectator_MapStateChanged
* RscDisplayEGSpectator_OnCursorObjectFocused
* RscDisplayEGSpectator_OnCursorObjectUnfocused
* RscDisplayEGSpectator_OnFocusChanged
* RscDisplayEGSpectator_OnUiVisibilityChanged
* RscDisplayRespawnKeyDown
* ScriptedEventHandlerAdded
* ScriptedEventHandlerRemoved |= Description
____________________________________________________________________________________________


| [namespace, name, code] call [[BIS_fnc_addScriptedEventHandler]]; |= Syntax
|p1= namespace: [[Namespace]], [[Object]], [[Group]], [[Location]], [[Boolean]], [[Control]] or [[Display]] - namespace in which the EH is stored


|p1= namespace: [[Namespace]], [[Object]], [[Group]], [[Location]], [[Boolean]], [[Control]] or [[Display]] - namespace in which handler is saved|=
|p2= name: [[String]] - event name
|p2= name: [[String]] - handler name|=
|p3= code: [[Code]] or [[String]] - code executed upon calling |=


| [[Number]] - id of the currently added event handler|= Return value
|p3= code: [[Code]] or [[String]] - the code that is executed when the EH fires. The magic variable [[Magic_Variables#thisScriptedEventHandler|_thisScriptedEventHandler]] can be used to access the event handler ID within the code.
____________________________________________________________________________________________


|r1= [[Number]] - the ID of the new Event Handler


|x1= <code><nowiki>[</nowiki>[[missionNamespace]], "event", {[[hint]] "Hello World"}] [[call]] [[BIS_fnc_addScriptedEventHandler]]; </code> |=
|x1= <sqf>[missionNamespace, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;</sqf>


|x2= <code><nowiki>[</nowiki>[[true]], "event", {[[hint]] "Hello World"}] [[call]] [[BIS_fnc_addScriptedEventHandler]]; </code>  
|x2= <sqf>[true, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;</sqf>  
Boolean will default to [[missionNamespace]] |=
Boolean will default to [[missionNamespace]].
____________________________________________________________________________________________
| [[BIS_fnc_callScriptedEventHandler]], [[BIS_fnc_removeScriptedEventHandler]], [[BIS_fnc_removeAllScriptedEventHandlers]] |= See also


|seealso= [[BIS_fnc_callScriptedEventHandler]] [[BIS_fnc_removeScriptedEventHandler]] [[BIS_fnc_removeAllScriptedEventHandlers]]
}}
}}
<h3 style="display:none">Notes</h3>
<dl class="command_description">
<!-- Note Section BEGIN -->
<!-- Note Section END -->
</dl>
<h3 style="display:none">Bottom Section</h3>
[[Category:Function Group: Misc|{{uc:addScriptedEventHandler}}]]
[[Category:Functions|{{uc:addScriptedEventHandler}}]]
[[Category:{{Name|arma3}}: Functions|{{uc:addScriptedEventHandler}}]]

Latest revision as of 16:50, 8 November 2023

Hover & click on the images for description

Description

Description:
Adds a Scripted Event Handler and returns its ID. Additionally, the "ScriptedEventHandlerAdded" Scripted EH is called. For the full list of all available Scripted EHs see Arma 3: Scripted Event Handlers.
Execution:
call
Groups:
Event Handlers

Syntax

Syntax:
[namespace, name, code] call BIS_fnc_addScriptedEventHandler
Parameters:
namespace: Namespace, Object, Group, Location, Boolean, Control or Display - namespace in which the EH is stored
name: String - event name
code: Code or String - the code that is executed when the EH fires. The magic variable _thisScriptedEventHandler can be used to access the event handler ID within the code.
Return Value:
Number - the ID of the new Event Handler

Examples

Example 1:
[missionNamespace, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;
Example 2:
[true, "event", { hint "Hello World" }] call BIS_fnc_addScriptedEventHandler;
Boolean will default to missionNamespace.

Additional Information

See also:
BIS_fnc_callScriptedEventHandler BIS_fnc_removeScriptedEventHandler BIS_fnc_removeAllScriptedEventHandlers

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