Jump to content
Sign in to follow this  
Scrocco88

Multiplayer and EventHandlers

Recommended Posts

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"""];
...

  1. Any suggestion?
  2. How can i consider unit not spawned yet using a loop? (Player hasn't joined the server yet)
  3. I assumed that init.sqf runs on every client when he joins the server. Is it right?
  4. 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

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×