MrSanchez 243 Posted July 14, 2015 Hi, I add an eventhandler to all playable AI in the mission using: { _x addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; _x setVariable ["PlayerName",name _x,true]; } foreach playableUnits; I then kill one of the AIs with a pistola and the rpt reports this: 21:19:59 C Alpha 1-1:1 21:19:59 C Alpha 1-1:1 21:19:59 C Alpha 1-1:1 21:19:59 C Alpha 2-3:1 (MrSanchez) in playerkilled.sqf I have: _victim = _this select 0; _killer = _this select 1; diag_log _victim; diag_log _killer; I am in MP LAN lobby when testing this. Does anyone know about this issue? Kind regards, Sanchez Share this post Link to post Share on other sites
R3vo 2654 Posted July 14, 2015 Where did you put { _x addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; _x setVariable ["PlayerName",name _x,true]; } foreach playableUnits; ? Share this post Link to post Share on other sites
MrSanchez 243 Posted July 14, 2015 (edited) In a spawn under init.sqf that gets executed once. I verified that the same issue happens when applying the eventhandler in-game, using a debug console (Tao's) I assign the eventhandler to the AI, then kill him...and receive double output. I tested this with both addEventhandler as well as addMPeventhandler....they both run twice. edit: There's quite a bunch of reports on this issue, primarily dating back to A2...http://forums.bistudio.com/showthread.php?102504-Multiplayer-amp-quot-killed-quot-eventhandler for instance... now it ain't the end of the world because I have a feeling that if I execute the code on players instead of AI it should work (that's when locality comes into play), but I do use this code for testing of my (onDeath) scripts. A workaround could be a while {alive} waituntil {!alive} loop I guess...:/ I'd rather just know what is wrong...I suspect it may be a game glitch or perhaps a mod of mine that breaks it (I'll try again without mods later) Any ideas? Kind regards, Sanchez Edited July 14, 2015 by PhonicStudios Share this post Link to post Share on other sites
dreadedentity 278 Posted July 15, 2015 I am in MP LAN lobby when testing this. In a spawn under init.sqf that gets executed once. Are you the server host or is it a dedicated server? Because if it's a dedicated server that you join, then init.sqf gets run for every player and the server. Share this post Link to post Share on other sites
das attorney 858 Posted July 15, 2015 ^^ this put something like: is (not isDedicated) then { player addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; player setVariable ["PlayerName",name player,true]; }; Share this post Link to post Share on other sites
R3vo 2654 Posted July 15, 2015 ^^ thisput something like: is (not isDedicated) then { player addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; player setVariable ["PlayerName",name player,true]; }; Wouldn't isServer be enough ? Share this post Link to post Share on other sites
das attorney 858 Posted July 15, 2015 No, If you put if (isServer) then { { _x addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; _x setVariable ["PlayerName",name _x,true]; } foreach playableUnits; }; You would only add the EH to any playableUnits at server init, so any JIPs wouldn't have the EH. Edit: It would be better to use: if (hasInterface) then { player addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; player setVariable ["PlayerName",name player,true]; }; In case you have HC. Share this post Link to post Share on other sites
R3vo 2654 Posted July 15, 2015 No, If you put if (isServer) then { { _x addeventhandler ["Killed", {_this execVM "playerkilled.sqf"}]; _x setVariable ["PlayerName",name _x,true]; } foreach playableUnits; }; Thanks for the clarification, but what about initPlayerLocal.sqf then ? As far as I understand this would execute the script for each player who joins, JIP and mission start. Share this post Link to post Share on other sites
das attorney 858 Posted July 15, 2015 You could do it that way as well if you want. Share this post Link to post Share on other sites
MrSanchez 243 Posted July 15, 2015 My thread got hijacked :@ Jk, back on topic; I am in fact the server host..I appreciate the help but I would like to quote myself: I verified that the same issue happens when applying the eventhandler in-game, using a debug console (Tao's) I assign the eventhandler to the AI, then kill him...and receive double output.I tested this with both addEventhandler as well as addMPeventhandler....they both run twice. I have yet to test this without mods but please go in-game, make a multiplayer LAN lobby (not SP editor) and add a killed eventhandler to a playable AI unit, using a console or whatever. When I do that and I kill the AI with a gun, the eventhandler is ran twice. Once where victim is also the killer (which would indicate collision) and then immediately after where victim is the AI and killer being myself (the correct result). Kind regards, Sanchez Share this post Link to post Share on other sites
das attorney 858 Posted July 15, 2015 What I wrote works fine on my PC (executed only once per player in MP). Share this post Link to post Share on other sites
MrSanchez 243 Posted July 15, 2015 Hi, Yes...I think that's where the misunderstanding is made..you see, I am actually testing with AIs for a reason. I am working on a scripted multiplayer gamemode and wanted to minimize my requirements for human beta testers by using AIs as test-subjects. I therefore want to execute my eventhandler on a playable AI (which, once the GM is ready, will be an actual player), and see the results when I kill one of the test-subjects. However, I think that this is a core ArmA 3 engine bug, but before I report it I'm going to test it without mods enabled (I finally have the opportunity to do so) I will keep things posted. Kind regards, Sanchez Share this post Link to post Share on other sites
killzone_kid 1330 Posted July 15, 2015 For the love of god, do not report it. There is no engine mengine bug, just some questionable scripting. Share this post Link to post Share on other sites
MrSanchez 243 Posted July 15, 2015 Don't worry. I wouldn't report anything until I am 100% certain it's a bug. If one would put up their glasses and read they'd know that. Jeeeeeeeeeeeeeeeeeeez. Kind regards, Sanchez Share this post Link to post Share on other sites
killzone_kid 1330 Posted July 15, 2015 I wouldn't report anything until I am 100% certain it's a bug There is no bug. Share this post Link to post Share on other sites
MrSanchez 243 Posted July 15, 2015 (edited) edit: Dayumn that's bigger than what I thought Well..just tested: Vanilla game, no bug indeed...works splendid. Modded game (using my community's modpack), bug(a bug is something that bugs me, mkay?) is there..eventhandler ran twice. I apologize for getting slightly agitated when one calls my scripting questionable, I don't like to think of myself as a newb to this language anymore. Either way, the problem has now shifted. I will have to go through my modpack and find what mod causes this. Does anyone know how one would make an eventhandler run twice? This may simplify my search through 50+ mods. Btw, here is the mission I used to test between vanilla and modded: https://dl.dropboxusercontent.com/u/23922015/ai_eventhandler_bug.VR.rar Kind regards, Sanchez ---------- Post added at 01:24 ---------- Previous post was at 01:09 ---------- Wow. It hardly took me some time. I found the problem; its ACE3. If you have ACE3 installed, launch it (w/ CBA ofcourse, but I tested CBA seperately, wasn't the problem), launch that mission of mine in the post above in a solo MP LAN lobby and notice how the message is duplicated (both in your screen as in .rpt) Guess I'll go complain in the ACE3 thread now.Go report it in their issue tracker. Thanks for the effort, lads. Kind regards, Sanchez Edited July 15, 2015 by PhonicStudios Share this post Link to post Share on other sites
Grumpy Old Man 3545 Posted October 16, 2018 3 hours ago, Andre Luis BR said: I'm having, sometimes, a strange behaviour after some player deaths that can be explained if the killed EH runs multiple times. So i ask: anyone noticed the situation where the killed EH, the only one, runs more than one time per death? Thanks! Any examples? Cheers Share this post Link to post Share on other sites
pierremgi 4862 Posted October 16, 2018 9 hours ago, Andre Luis BR said: I'm having, sometimes, a strange behaviour after some player deaths that can be explained if the killed EH runs multiple times. So i ask: anyone noticed the situation where the killed EH, the only one, runs more than one time per death? Thanks! How do you know that EH run twice? I've never that. More probably, the code inside EH is poorly written. Share this post Link to post Share on other sites