Jump to content
Sign in to follow this  
Norm49

killed event handeler

Recommended Posts

Hi I'm trying to create a event handler the will fire every time the player kill a unit. The script to execute is simple it will only be a = 1. The variable a is to be call in trigger that is currently working as intended. What i try doesn't work.

 

I create a init.sqf file and put this in it.

 

_x addEventHandler ["Killed",
        {
            [_this select 0, _this select 1]if (isPlayer _killer) then a = 1;
        } foreach allunits;

 

 

Form all my try and research during the last 4 hours that the best i came with and it still doesn't work.

 

Thanks for any assistance with this.

Share this post


Link to post
Share on other sites

Hello,

 

Unfortunately your syntax is wrong, check wiki:

https://community.bistudio.com/wiki/forEach

https://community.bistudio.com/wiki/Arma_3:_Event_Handlers#Killed

 

It's better to use the params given in the examples on the wiki. Keeps things simple and clear for everyone.

In order to use the variable _killer you need to pass it down first through params.

 

Variable a is too vague as well as it can be easily overwritten and you should make it more explicit.

 

{
	_x addEventHandler ["Killed", {
		params ["_unit", "_killer", "_instigator", "_useEffects"];
		if (isPlayer _killer) then{a = 1};
	}];
}foreach allunits; 
  • Thanks 1

Share this post


Link to post
Share on other sites

The variable "a" was use just temporally for debugging any ways it now work as intended thanks!

  • Like 1

Share this post


Link to post
Share on other sites
// init.sqf
if (hasInterface) then {
	addMissionEventHandler [
		'EntityKilled',
		{
			params ['_killed','_killer'];
			
			if (_killer isequalto player) then {
			
			};
		
		}
	];
};

 

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  

×