Jump to content
Sign in to follow this  
LeadCommando65

Multiplayer & "killed" eventhandler

Recommended Posts

Hi,

my mission uses an eventhandler "killed". It's attached to all playable units and executes a script when triggered. It's like this:

//init line of leading player
{ _x addEventHandler ["killed", "_this execVM ""myFavScript.sqf"""]; } foreach playableUnits;

//myFavScript.sqf
counter = counter + 1;
publicvariable "counter";

//variable "counter" was set to 0 by the init.sqf file

Now I've one problem which I couldn't think of a proper solution: When I am hosting the server and an AI unit takes control of the playable unit and the eventhandler gets triggered, the script is executed twice (counter is set to 2, if someone gets killed; every kill on a playable unit adds 2 instead of 1 as it should do).

I don't know where that comes from. Is that even possible or do I have overlooked something in my mission that causes the script to be executed twice? Do you have any solution to this?

I thought it's one of those freaking client/server things, so that I have to use a command like isServer or local, but I haven't figured out how I can apply it and still have the script properly executed in both situations of dedicated and player hosted servers. Can anyone please help?

Thanks in advance.

Regards,

LeadCommando65

//EDIT:

Now I've found out what the problem is caused by, but still no solution: My mission is using the FirstAid modules. When a playable AI, which is not in my group, gets killed, the eventhandler is fired twice (still if hosting the server by myself). I don't know how to workaround this or why it is actually caused by the FirstAid modules. Can you help me, please?

//EDIT2:

Nevermind, problem solved.

The modules broke the eventhandler, so I removed them. But I found a workaround: I used a similar revive script like this instead: doorevive

Very bad job of BI. The community has to rescript functions already implemented in the game to make them work properly. :( :( :mad:

Edited by LeadCommando65

Share this post


Link to post
Share on other sites

if(Isplayer (_this select 0))then

{

counter = counter + 1;

publicvariable "counter";

};

// _this select 0, is the first element that the killed event handler passes to the script, which happens to be the killed unit

Share this post


Link to post
Share on other sites

As said above execute it for players only

also using playAbleUnits is waste of resources just add it to the player himself it will work for all when its executed on all clients.

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  

×