mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
More event handler changes! Added removeEventHandler and removeAllEventHandler, changed name from addNetEventHandler to addEventHandler, and added a localEvent function.
This commit is contained in:
parent
ccc3b9d076
commit
9a37538d50
@ -138,13 +138,16 @@ PREP(addCuratorUnloadEventhandler);
|
||||
PREP(fixCrateContent);
|
||||
|
||||
//ACE events global variables
|
||||
GVAR(netEvents) = [[],[]];
|
||||
GVAR(events) = [[],[]];
|
||||
|
||||
PREP(globalEvent);
|
||||
PREP(_handleNetEvent);
|
||||
PREP(addNetEventHandler);
|
||||
PREP(addEventHandler);
|
||||
PREP(targetEvent);
|
||||
PREP(serverEvent);
|
||||
PREP(localEvent);
|
||||
PREP(removeEventHandler);
|
||||
PREP(removeAlLEventHandlers);
|
||||
|
||||
|
||||
// Loop to update the ACE_player variable
|
||||
|
@ -12,10 +12,10 @@ if(_eventType == "ACEg") then {
|
||||
_eventName = _event select 0;
|
||||
_eventArgs = _event select 1;
|
||||
|
||||
_eventNames = GVAR(netEvents) select 0;
|
||||
_eventNames = GVAR(events) select 0;
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
if(_eventIndex != -1) then {
|
||||
_events = (GVAR(netEvents) select 1) select _eventIndex;
|
||||
_events = (GVAR(events) select 1) select _eventIndex;
|
||||
{
|
||||
if(!isNil "_x") then {
|
||||
_eventArgs call CALLSTACK_NAMED(_x, format[ARR_3("Net Event %1 ID: %2",_eventName,_forEachIndex)]);
|
||||
|
@ -1,14 +1,14 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Add a network event handler.
|
||||
* Add a event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 1: Event code (code)
|
||||
*
|
||||
* Return value:
|
||||
* Event handler ID number (for use with fnc_removeNetEventHandler)
|
||||
* Event handler ID number (for use with fnc_removeEventHandler)
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_eventName", "_eventCode", "_eventNames", "_eventFunctions", "_eventNameCount", "_eventIndex", "_eventFunctionCount"];
|
27
addons/common/functions/fnc_localEvent.sqf
Normal file
27
addons/common/functions/fnc_localEvent.sqf
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Execute a local event on this client only.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 1: Event args (any)
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
|
||||
_eventName = _this select 0;
|
||||
_eventArgs = _this select 1;
|
||||
|
||||
_eventNames = GVAR(events) select 0;
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
if(_eventIndex != -1) then {
|
||||
_events = (GVAR(events) select 1) select _eventIndex;
|
||||
{
|
||||
if(!isNil "_x") then {
|
||||
_eventArgs call CALLSTACK_NAMED(_x, format[ARR_3("Local Event %1 ID: %2",_eventName,_forEachIndex)]);
|
||||
};
|
||||
} forEach _events;
|
||||
};
|
21
addons/common/functions/fnc_removeAllEventHandlers.sqf
Normal file
21
addons/common/functions/fnc_removeAllEventHandlers.sqf
Normal file
@ -0,0 +1,21 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Remove all events of a certain event type.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_eventName", "_eventNames", "_eventFunctions", "_eventIndex"];
|
||||
_eventName = _this select 0;
|
||||
|
||||
_eventNames = GVAR(netEvents) select 0;
|
||||
_eventFunctions = [];
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
if(_eventIndex != -1) then {
|
||||
(GVAR(netEvents) select 1) set[_eventIndex, []];
|
||||
};
|
24
addons/common/functions/fnc_removeEventHandler.sqf
Normal file
24
addons/common/functions/fnc_removeEventHandler.sqf
Normal file
@ -0,0 +1,24 @@
|
||||
/*
|
||||
* Author: Nou
|
||||
*
|
||||
* Remove an event handler.
|
||||
*
|
||||
* Argument:
|
||||
* 0: Event name (string)
|
||||
* 1: Event code (number)
|
||||
*
|
||||
* Return value:
|
||||
* Nothing
|
||||
*/
|
||||
#include "script_component.hpp"
|
||||
private ["_eventName", "_eventNames", "_eventFunctions", "_eventIndex", "_eventCodeIndex"];
|
||||
_eventName = _this select 0;
|
||||
_eventCodeIndex = _this select 1;
|
||||
|
||||
_eventNames = GVAR(netEvents) select 0;
|
||||
_eventFunctions = [];
|
||||
_eventIndex = _eventNames find _eventName;
|
||||
if(_eventIndex != -1) then {
|
||||
_eventFunctions = (GVAR(netEvents) select 1) select _eventIndex;
|
||||
_eventFunctions set[_eventCodeIndex, nil];
|
||||
};
|
Loading…
Reference in New Issue
Block a user