Search the Community
Showing results for tags 'spawntickets'.
Found 1 result
-
Punishment when killing civi's by players
Spoor posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
@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- 2 replies
-
- civilians
- spawntickets
-
(and 1 more)
Tagged with: