Jump to content
Sign in to follow this  
stevoau

Killed EventHandler weird behaviour - "BIS_fnc_setObjectVar_object1"

Recommended Posts

Hey guys I've run into a bit of a problem with the killed eventhandler on spawned units. I'm trying to get it to return the object that was killed and the killer as it should but things are a but wonky.

// UNIT GET SPAWNED AND THIS EH IS ADDED
_newUnit addEventHandler ["killed", {_nul = [(_this select 0), (_this select 1)] call killedEH}];
//CODE CODE CODE

killedEh

killedEH =
{
_deadGuy = _this select 0; //Works
_killer = _this select 1;     //Doesn't
_side = side _deadguy;
hint format ["%1 \n%2", _this select 0, _this select 1];  //Returns: killed unit, BIS_fnc_setObjectVar_object1
if(_side == Civlian) then
{
	_points = _killer getVariable "points";
	_points = _p - 100;
	_killer setVariable ["points", _points];
	_killer groupChat format ["%1 WATCH YOUR FIRE", _killer];
};
if(_side == East) then
{	
	_p = _killer getVariable "p";
	_p = _p + 100;
	_killer setVariable ["p", _p];
};
};

Returns the unit that was killed but instead of returning the killer it returns "BIS_fnc_setObjectVar_object1", when running the event handler (the one that calls killedEH) from a units init-line it still has the same problem.

I tested the eventhandler in the init box of another unit to make sure it was working but instead of calling killedEH it prints to a hint straight away, it works and displays the dead guy and the killer.

this addEventHandler ["Killed",{hint format ["%1 was killed by %2",name (_this select 0),name (_this select 1)];}]

EDIT: Just realized what was happening I forgot to give the player a name and misspelled 'Civilian', brain fart hehe.

Edited by StevoAU

Share this post


Link to post
Share on other sites

_nul = [(_this select 0), (_this select 1)] call killedEH

is the same as

_nul = _this call killedEH

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×