Spoor 23 Posted July 13, 2018 @pierremgi - TvT 50/50 Campaign - You have to help me onesmore. As said earlier I would like to punish players when they kill a civilian (AI). The max number off civilians during the mission will be 6. When placing the script in the unit init it works all fine but only for 2 kills. I have been trying the use the addition codes too but dnt succeed unfortunately. Dnt forget noob here but love doing this - appreciate yr help - thanks quote Posted February 6 civilian men? I can't test it but try: this addEventHandler ["killed",{ params ["_killed","_killer","_instigator","_side"]; if (([_killed,true] call bis_fnc_objectSide == civilian or captive _killed) && !isnull _instigator) exitWith { [side _instigator,-1,false] call BIS_fnc_respawnTickets }; if (count crew _killed >0) then { _side = [_killed,false] call bis_fnc_objectSide } else { _side = [_killed,true] call bis_fnc_objectSide }; [_side,-1,false] call BIS_fnc_respawnTickets }]; The problem is what you want to protect with that. I guess you can't copy/paste this code in all init fields of the units/vehicles. So you can define an array of units. Never mind the method, just think about edited (3den) or spawned (in game). The second case needs a loop to refresh the array but, without treating the former units again and again. First, the code is: { _x addEventHandler [.....] } foreach AnArrayOfUnits; // can be [bob1,bob2,bob3] but also allUnits for example (men only), or vehicles (as written) or allUnits + vehicles Second, if you spawn some new units, you need to track the new units and "treat" them with EH. Two ways: You treat them, immediatly once they spawn (I kept the case of an array here): { _x addEventHandler [....] } forEach arrayOfNewSpawnedUnits; // just after spawning code or make a loop in init.sqf, waiting for some new arrival, considering general arrays like allUnits or vehicles: [] spawn { while {true} do { { _x setVariable ["treated",true]; _x addEventHandler [....] } forEach AnArrayOfUnits select { !(_x getVariable ["treated",false]) }; // works fine with allUnits or vehicles } }; unquote Share this post Link to post Share on other sites
pierremgi 4740 Posted July 13, 2018 0 = [] spawn { while {true} do { { _x setVariable ["EHPunish",true,true]; _x addEventHandler ["killed",{ params ["_killed","_killer","_instigator","_side"]; call { if (_killed == _instigator or isNull _instigator) exitWith {}; if (side _instigator isEqualTo sideEnemy) exitWith { [_instigator,-1,true] call bis_fnc_respawnTickets }; if (([_killed,true] call bis_fnc_objectSide == civilian or captive _killed) && !isnull _instigator) exitWith { [side _instigator,-1,false] call BIS_fnc_respawnTickets }; if (count crew _killed >0) then { _side = [_killed,false] call bis_fnc_objectSide } else { _side = [_killed,true] call bis_fnc_objectSide }; [_side,-1,false] call BIS_fnc_respawnTickets }; } ]} forEach (allUnits select {isNil {_x getVariable "EHPunish"}}); uisleep 5; } }; The 2 tickets limitation was due to the player becoming renegade (side enemy) when killing more than 2 civs. added a specific condition to punish the renegade. Usually renagade doesn't live for a long time if AIs in area. If you want to avoid this problem (side enemy), you can write: player addRating 1000000; in intiPlayerLocal.sqf. So, the respawn ticket will be the unique punishment for players. Share this post Link to post Share on other sites
Spoor 23 Posted July 14, 2018 @pierremgi - you made my day - thanks - both scripts working just fine with this "player addRating 1000000;" included. Using yr last script - thanks again Share this post Link to post Share on other sites