removeMissionEventHandler: Difference between revisions

From Bohemia Interactive Community
Jump to navigation Jump to search
(Created page with "{{Command|= Comments ____________________________________________________________________________________________ | arma3 |= Game name |0.50|= Game version ____________________...")
 
m (Text replacement - "<sqf>([^↵][^<]*↵[^<]*)<\/sqf>" to "<sqf> $1 </sqf>")
 
(54 intermediate revisions by 8 users not shown)
Line 1: Line 1:
{{Command|= Comments
{{RV|type=command
____________________________________________________________________________________________


| arma3 |= Game name
|game1= arma3
|version1= 0.50


|0.50|= Game version
|eff= local
____________________________________________________________________________________________


| Removes mission event handler added by [[addMissionEventHandler]].
|gr1= Event Handlers
When any handler is removed, all handler indices higher that the deleted one should be decremented. |= Description
____________________________________________________________________________________________


| '''removeMissionEventHandler''' [type, index] |= Syntax
|descr= Removes mission event handler added by [[addMissionEventHandler]].


|p1= type: [[String]] |= PARAMETER1
|s1= [[removeMissionEventHandler]] [type, index]


|p2= index: [[Number]] - Index is returned by addMissionEventHandler. |= PARAMETER2
|p1= type: [[String]]


| [[Nothing]] |= RETURNVALUE
|p2= index: [[Number]] - index is returned by addMissionEventHandler.


|r1= [[Nothing]]


|x1= <code></code>|= EXAMPLE1
|x1= <sqf>
private _eventHandlerId = addMissionEventHandler ["Ended", { diag_log "mission complete"; }];
// ...
removeMissionEventHandler ["Ended", _eventHandlerId];
</sqf>


____________________________________________________________________________________________
|x2= <sqf>
for "_i" from 0 to 4 do {
missionNamespace setVariable [format ["handler%1",_i], addMissionEventHandler ["Loaded","hint ""_i"";"]];
};
removeMissionEventHandler ["Loaded", handler2]; // Remove the third index under type "Loaded"
</sqf>


| |= SEEALSO
|x3= <sqf>addMissionEventHandler ["entityKilled",{hint "First kill!"; removeMissionEventHandler ["entityKilled", _thisEventHandler]; }];</sqf>


| |= MPBEHAVIOUR
|seealso= [[addMissionEventHandler]] [[removeAllMissionEventHandlers]]
____________________________________________________________________________________________
}}
}}


<h3 style='display:none'>Notes</h3>
<dl class="command_description">
<dl class='command_description'>
 
<!-- Note Section BEGIN -->
<dt><dt>
<dd class="notedate">Posted on 2015-08-06 - 22:02 (UTC)</dd>
<dt class="note">[[User:SilentSpike|SilentSpike]]</dt>
<dd class="note">
As of Arma 3 version 1.38 you can safely remove mission event handlers without worrying about decrementing higher indices.<br>
'''EDIT:''' this command used to decrement other EH ids above the deleted one (e.g EH 0,1,2,3, delete EH 1, EH would be 0,1,2 now and not 0,2,3) - [[User:Lou Montana|Lou Montana]] ([[User talk:Lou Montana|talk]]) 19:29, 25 June 2020 (CEST)
</dd>


<!-- Note Section END -->
</dl>
</dl>
<h3 style='display:none'>Bottom Section</h3>
[[Category:Arma_3:_New_Scripting_Commands_List|{{uc:{{PAGENAME}}}}]]
[[Category:Scripting Commands|{{uc:{{PAGENAME}}}}]]

Latest revision as of 19:42, 3 September 2024

Hover & click on the images for description

Description

Description:
Removes mission event handler added by addMissionEventHandler.
Groups:
Event Handlers

Syntax

Syntax:
removeMissionEventHandler [type, index]
Parameters:
type: String
index: Number - index is returned by addMissionEventHandler.
Return Value:
Nothing

Examples

Example 1:
private _eventHandlerId = addMissionEventHandler ["Ended", { diag_log "mission complete"; }]; // ... removeMissionEventHandler ["Ended", _eventHandlerId];
Example 2:
for "_i" from 0 to 4 do { missionNamespace setVariable [format ["handler%1",_i], addMissionEventHandler ["Loaded","hint ""_i"";"]]; }; removeMissionEventHandler ["Loaded", handler2]; // Remove the third index under type "Loaded"
Example 3:
addMissionEventHandler ["entityKilled",{hint "First kill!"; removeMissionEventHandler ["entityKilled", _thisEventHandler]; }];

Additional Information

See also:
addMissionEventHandler removeAllMissionEventHandlers

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 2015-08-06 - 22:02 (UTC)
SilentSpike
As of Arma 3 version 1.38 you can safely remove mission event handlers without worrying about decrementing higher indices.
EDIT: this command used to decrement other EH ids above the deleted one (e.g EH 0,1,2,3, delete EH 1, EH would be 0,1,2 now and not 0,2,3) - Lou Montana (talk) 19:29, 25 June 2020 (CEST)