DarealAl 10 Posted September 17, 2014 Hey there... I am verry new to Arma-Scripting at all, i googled a lot and tested a lot but i cant find the answer... Is there any1 able to tell me why this code shows target and killer as the same when the target is killed by KI ? if (!isServer) exitwith{}; _target addMPEventHandler ["mpkilled", {_this call f_Kill}]; f_Kill = { killer = _this select 1; killerName = name killer; publicVariable "killer"; publicVariable "killerName"; hint format ["Target was killed by %1",killerName]; }; Share this post Link to post Share on other sites
Rich44 10 Posted September 18, 2014 It entirely depends on what _target is. Also, publicVariable "killer" could cause issues on other clients, what if two people are killed at the same time? You *could* potentially end up with multiple death messages for the same person. Share this post Link to post Share on other sites
DarealAl 10 Posted September 18, 2014 (edited) _target is a randomly selected Player from playableUnits. i tried _killer b4 but had the same Problem if (!isServer) exitwith {}; // Select random Player _players = playableUnits; _target = _players select (floor (random (count _players))); _targetName = name _target; // Add EventHandler to the selected Player _target addMPEventHandler ["mpkilled", {_this call f_Kill}]; // Function to be executed when selected Player is killed f_Kill = { _killer = _this select 1; _killerName = name _killer; hint format ["Target was killed by %1",killerName]; }; // Wait for selected Player to die waitUntil { sleep 10; ! alive _target; }; // Remove EventHandler _target removeAllMPEventHandlers "mpkilled"; Edited September 18, 2014 by DarealAl Share this post Link to post Share on other sites
jshock 513 Posted September 18, 2014 (edited) I know functions are faster and all, but wouldn't it just be easier to do it all within the EH and then assign the EH to all the players: { if (isPlayer _x) then { _x addMPEventHandler ["mpkilled", {hint format ["%1 was killed by %2",(_this select 0), (_this select 1)];}]; }foreach allunits; Edited September 18, 2014 by JShock Share this post Link to post Share on other sites
DarealAl 10 Posted September 18, 2014 (edited) There is only 1 Player with that handler and always will be... The Problem is, as in the Topic, i always get the target as killer when the target is killed by KI. In fact, later need to check if killer == target // suicide killer == KI // Bad luck killer == other Player // Perfekt but when the code always returns killer==target i can put my projekt to trash :( Edited September 18, 2014 by DarealAl Share this post Link to post Share on other sites
jshock 513 Posted September 18, 2014 What or who is KI, I'm lost there... But I don't see why this code couldn't work: player addMPEventHandler ["mpkilled", {hint format ["%1 was killed by %2",(_this select 0), (_this select 1)];}]; Share this post Link to post Share on other sites
DarealAl 10 Posted September 19, 2014 ARGS.. Sorry.. stupid german around... (me) ... KI == AI *shame Share this post Link to post Share on other sites
jshock 513 Posted September 19, 2014 Maybe see if the normal Killed EH fixes it??? player addEventHandler ["Killed", {hint format ["%1 was killed by %2",(_this select 0), (_this select 1)];}]; But other than that, I would be lost as to why it's returning the wrong name. Share this post Link to post Share on other sites
DarealAl 10 Posted September 19, 2014 Is it suggested to use "killed" in multiplayer missions ? i always think the "mpkilled" is for MP missions. Share this post Link to post Share on other sites
jshock 513 Posted September 19, 2014 Is it suggested to use "killed" in multiplayer missions ? i always think the "mpkilled" is for MP missions. The only difference between the two that I saw on the EH page was the the MP was executed on all machines, opposed from the normal Killed EH. But like I said, I'm now just speculating. Share this post Link to post Share on other sites