Alpine_gremlin 13 Posted October 13, 2018 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
davidoss 550 Posted October 13, 2018 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. 1 Share this post Link to post Share on other sites
Alpine_gremlin 13 Posted October 13, 2018 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
davidoss 550 Posted October 13, 2018 https://community.bistudio.com/wiki/params [ "_instigator" , objNull , [objNull] ] [ assign some variable , set assigned variable default value (used when nil (not passed param) , [set allowed data types for assigned variable value] ] Share this post Link to post Share on other sites
Grumpy Old Man 3540 Posted October 14, 2018 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 2 Share this post Link to post Share on other sites
Tankbuster 1733 Posted October 14, 2018 In units group 1 Share this post Link to post Share on other sites