Jump to content
Alpine_gremlin

"Hit" Event Handler Params

Recommended Posts

Hey guys, so I`m trying to set up a scenario where the player gets betrayed by a specific group. One way I`m thinking of triggering the event is to have him get shot (not killed though) by one of the group members.

 

I have this:

player addEventHandler 
["Hit",{
	params ["_unit", "_source", "_damage", "_instigator"];
	if (_this select 3 in traitorGrp) then 
		{betray = true};}
];

When I try to use this however, I get "Error in: type group, expected array, object, location"

 

As you can see I am trying to check if the shooter is in the specified group, and if so, set the variable. Is a group not an array however? Additionally I`m quite sure that "_instigator" is most certainly a unit.  I`m not quite sure how to approach this. Using the side command did not seem to work either.

Share this post


Link to post
Share on other sites
betray = false;

player addEventHandler ["Hit",{
	params [
		["_unit",objNull,[objNull]],
		["_source",objNull,[objNull]],
		["_damage",0,[0]],
		["_instigator",objNull,[objNull]]
	];
	
	if (!isNull _instigator && {_instigator in (units traitorGrp)}) exitWith {betray = true};
}];

Comparing sides should work either:

 

 if (!isNull _instigator && {(side _instigator) isEqualTo (side _unit)}) exitWith {betray = true};

 

 

Take eh limitations in consideration:

 

Is not always triggered when unit is killed by a hit.
Most of the time only the killed event handler is triggered when a unit dies from a hit.
The hit EH will not necessarily fire if only minor damage occurred (e.g. firing a bullet at a tank), even though the damage increased.
Does not fire when a unit is set to allowDamage false.

  • Thanks 1

Share this post


Link to post
Share on other sites

Hey man thanks a lot!

 

Would you mind explaining what you did differently in the params? I`m still trying to get practice with that command.

Share this post


Link to post
Share on other sites
9 hours ago, Alpine_gremlin said:

Hey guys, so I`m trying to set up a scenario where the player gets betrayed by a specific group. One way I`m thinking of triggering the event is to have him get shot (not killed though) by one of the group members.

 

I have this:


player addEventHandler 
["Hit",{
	params ["_unit", "_source", "_damage", "_instigator"];
	if (_this select 3 in traitorGrp) then 
		{betray = true};}
];

When I try to use this however, I get "Error in: type group, expected array, object, location"

 

As you can see I am trying to check if the shooter is in the specified group, and if so, set the variable. Is a group not an array however? Additionally I`m quite sure that "_instigator" is most certainly a unit.  I`m not quite sure how to approach this. Using the side command did not seem to work either.

Group is its own data type, similar to object, location or array.

The "in" command needs either a vehicle, to find if a unit is inside it, or an array, to check if an element exists inside an array.

Group is of data type group, so the "in" command doesn't work, hence why you need "units group".

 

Cheers

  • Like 2

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

×