Page MenuHomeFeedback Tracker

You can rewrite the EventHandler parameters inside the script.
New, NormalPublic

Description

There is an access to overwriting the parameters of the event handler. The event, which was previously registered, can change the input data.

Details

Severity
Major
Resolution
Open
Reproducibility
Always
Operating System
Windows 7 x64
Category
Scripting
Steps To Reproduce

In the first event, the code will change the instigator parameter to objNull, which in the second event will return objNull, instead of "B Alpha 1-2: 1 (Dell)"

sqf
_unit = cursorObject;
_unit addEventHandler ["Killed", {
	// "Killed #0 (425.779): [B Alpha 1-1:1,B Alpha 1-2:1 (Dell),B Alpha 1-2:1 (Dell),true]"
	diag_log format["Killed #%1 (%2): %3", _thisEventHandler, diag_tickTime, _this];
	_this set [2, objNull];
}];
_unit addEventHandler ["Killed", {
	// "Killed #1 (425.779): [B Alpha  1-1:1,B Alpha 1-2:1 (Dell),<NULL-object>, true]"
	diag_log format["Killed #%1 (%2): %3", _thisEventHandler, diag_tickTime, _this];
}];

rpt:
20:54:56 "Killed #0 (425.779): [B Alpha 1-1:1,B Alpha 1-2:1 (Dell),B Alpha 1-2:1 (Dell),true]"
20:54:56 "Killed #1 (425.779): [B Alpha 1-1:1,B Alpha 1-2:1 (Dell),<NULL-object>,true]"

Additional Information

Also it was noticed with the events HandleDamage. With other eventHandler it was not tested.

I would like to know whether this is an idea or not? Will this be fixed, can this be used to add a killer by using ` _unit setDamage 1```

sqf
// The first-ever event
_unit addEventHandler ["Killed", {
	params ["_unit", "_killer", "_instigator"];
	if (_unit isEqualTo _killer && _unit isEqualTo _instigator) then {
		_this set [1, _unit getVariable ["killer", _this # 1]];
		_this set [2, _unit getVariable ["instigator", _this # 2]];
	};
}];
 sqf
// fnc_DeadUnit
params [["_unit", objNull, [objNull]], ["_killer", objNull, [onjNull]], ["_insigator", objNull, [objNull]]];
_unit setVariable ["Killer", _killer];
_unit setVariable ["Insigator", _insigator];
_unit setDamage 1;

Event Timeline

Dell created this task.Sep 4 2018, 8:05 PM
Dell edited Steps To Reproduce. (Show Details)Sep 4 2018, 8:10 PM
Dell edited Additional Information. (Show Details)
Dell edited Steps To Reproduce. (Show Details)
Dell edited Additional Information. (Show Details)Sep 4 2018, 8:17 PM
Dell edited Additional Information. (Show Details)Sep 5 2018, 7:23 AM
Dell edited Additional Information. (Show Details)Sep 5 2018, 1:06 PM