Scrocco88 1 Posted March 11, 2013 Hi, maybe this is a stupid question but i couldn't figure it out. I need to perform an action when any player dies (MP only, PvP map). So i tried to add an EventHandler to anyone. I tried this in init.sqf if (isServer) then { { _x addEventHandler ["killed", "kc = _this execVM ""killcount.sqf"""]; }foreach allUnits; } In the editor preview (with AI players) anything goes right, but in MP missions it works only with some players. I think the problem is that players joining the server after it started were not in the allUnits loop, so i edited in this way... but it still doesn't work. Init.sqf if (isServer) then { ... { if (!isPlayer _x) then { // To test it with AI units _x addEventHandler ["killed", "kc = _this execVM ""killcount.sqf"""]; }; }foreach allUnits; }; ... waitUntil {alive player}; player addEventHandler ["killed", "kc = _this execVM ""killcount.sqf"""]; ... Any suggestion? How can i consider unit not spawned yet using a loop? (Player hasn't joined the server yet) I assumed that init.sqf runs on every client when he joins the server. Is it right? It works if i set the handler in the "init" field of the unit. Can i do it automatically using a script loop? Share this post Link to post Share on other sites
cuel 25 Posted March 11, 2013 You'd use the MPEventHandler, not the regular one since it is only triggered where the unit is local. http://community.bistudio.com/wiki/addMPEventHandler Share this post Link to post Share on other sites