Jump to content
Sign in to follow this  
kaski

deleteVehicle triggers "killed", ways to avoid this?

Recommended Posts

EDIT: Actually it doesn't. I created a public bool which returns true if script is deleting civs too far away, and false if it is not. I still get civ kills eventho I have exitWith if bool = true in civKilled.sqf. I guess civs drive over other civs or they spawn inside things and die.. :(

I am trying to create a mission for me and my friends. I have implemented Civilian Occupation System (COS) script which spawns civilians to cities when player is close enough them.

_unit = _grp createUnit [_tempUnit, _tempPos, [], 0, "NONE"];	

I am also trying to count players civilian kills and fail the mission if it is too much. I have in the init.sqf a public variable that is set to 10. On COS script, every unit it spawns will run this on them:

_unit addEventHandler ["killed", { [] execVM "scripts\civKilled.sqf";}];

This is my civKilled.sqf:

CIV_CivilianKillsRemaining = CIV_CivilianKillsRemaining - 1;
publicVariable "CIV_CivilianKillsRemaining";

hintsilent format ["You killed a civilian!\n\n %1 more kills and you fail your mission!",CIV_CivilianKillsRemaining];

if(CIV_CivilianKillsRemaining <= 0) then {
	failMission "LOSER";
};

If the civilian isn't on certain range of player, it will be deleted via deleteVehicle which is OK. However, seems like deleteVehicle triggers the addEventHandler "killed" and this will eventually fail the mission when enough civilians despawns.. Is there a workaround this?

Edited by kaski

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
Sign in to follow this  

×