Search the Community
Showing results for tags '_killed'.
Found 1 result
-
Vehicle respawn with EntityKilled EH
Asmodeuz posted a topic in ARMA 3 - MISSION EDITING & SCRIPTING
Hello, through trial and testing I've arrived to the following format for a vehicle respawn functionality. addMissionEventHandler ["EntityKilled", { params ["_killed", "_killer", "_instigator"]; [_killed] spawn { switch (true) do { case (!alive vehCivSUV_1): {deleteVehicle vehCivSUV_1; _newVehicle2 = "C_SUV_01_F" createVehicle [1263,1298,0]; _newVehicle2 setVehicleVarName "vehCivSUV_1"; vehCivSUV_1 = _newVehicle2; publicVariable "vehCivSUV_1";}; sleep 2; case (!alive vehCivSUV_2): {deleteVehicle vehCivSUV_2; _newVehicle = "C_SUV_01_F" createVehicle [1232,1298,0]; _newVehicle setVehicleVarName "vehCivSUV_2"; vehCivSUV_2 = _newVehicle; publicVariable "vehCivSUV_2";}; }; }; }]; While testing has proven that it works decently enough in a dedicated server there's still at least one edge-case scenario that I'd like to iron out. The edge-case is that should the two vehicles mentioned in the event handlers code be destroyed exactly at the same time the functionality does not work as expected. Should the demise of both vehicles happen at the same time the other vehicle won't be created at all (and the other that gets created will have a duplicate vehicle spawned next to it). So while what I have now works to some degree there should be some changes made to make the functionality more robust. Maybe the switch-do is not the best solution but I have only just arrived to that and don't have off the top of my head any other solution to try. So question for this is that: what would be a more robust way to achieve what I have now and do away with the edge-case scenario at the same time? Another thing would be that the functionality should, if possible, incorporate at least two more vehicles in it. edit: while I know that there's a respawn module available in the editor that can't be used for "reasons"