CBA_fnc_addClassEventHandler

Description

Add an eventhandler to a class and all children.

Parameters

0: _classNameThe classname of objects you wish to add the eventhandler too.  Can be a base class.  STRING
1: _eventNameThe type of the eventhandler.  E.g.  “init”, “fired”, “killed” etc.  STRING
2: _eventFuncFunction to execute when event happens.  <CODE>
3: _allowInheritanceAllow event for objects that only inherit from the given classname?  [optional] <BOOLEAN> (default: true)
4: _excludedClassesExclude these classes from this event including their children [optional] ARRAY (default: [])
5: _applyInitRetroactivelyApply “init” event type on existing units that have already been initilized.  [optional] <BOOLEAN> ((default: false)

Returns

_successWhether adding the event was successful or not.  <BOOLEAN>

Examples

["CAManBase", "fired", {systemChat str _this}] call CBA_fnc_addClassEventHandler;
["All", "init", {systemChat str _this}] call CBA_fnc_addClassEventHandler;
["Car", "init", {(_this select 0) engineOn true}, true, [], true] call CBA_fnc_addClassEventHandler; //Starts all current cars and those created later

Author

commy2

string used by format
Array to read from [Array]
Close