Asmodeuz 53 Posted July 5, 2017 The below script is intended to act as a functionality that checks if the killer is player and whether killed is either on the same side as the player or on the enemy side. _TK = addMissionEventHandler ["EntityKilled", { params["_killed", "_killer", "_instigator"]; if ((side _killer == playerSide) && (side group _killed == playerSide) || (side group _killed != playerSide)) then { _this = _this select 0; {_this removeMagazine _x} forEach magazines _this; removeAllItems _this; removeAllAssignedItems _this; }; }]; When a player kills either a friendly soldier or an enemy soldier the code should make it so that all the items and magazines get removed from the now deceased. The code itself works very well for the case: if ((side _killer == playerSide) && (side group _killed == playerSide) but not so well for the case if ((side _killer == playerSide) || (side group _killed != playerSide)) Very often in this particluar case ammunition and items can be picked from the killed enemy soldiers. As much as I understand to read the code it should work as follows: If player is killer AND killed is friendly OR killed is not friendly (is enemy in this case) then remove all items and magazines What I might be missing here? Or should I be looking for completely another approach for what I'm trying to achieve here? Share this post Link to post Share on other sites
f2k sel 163 Posted July 5, 2017 if ((side _killer == playerSide) || (side group _killed != playerSide)) Works fine for me in SP, I killed about 10-20 units and there were no Items or ammo found. 1 Share this post Link to post Share on other sites
Asmodeuz 53 Posted July 6, 2017 18 hours ago, f2k sel said: if ((side _killer == playerSide) || (side group _killed != playerSide)) Works fine for me in SP, I killed about 10-20 units and there were no Items or ammo found. I have to apologize for not being thorough enough in my initial post. It is true that when testing eg. from the in-game editor (multiplayer mode) the whole script works very well, even the if ((side _killer == playerSide) || (side group _killed != playerSide)) case. The actual problem which I forgot to mention that it should also work in dedicated server, which it doesn't. In a dedicated server the problem is only with the aforementioned || (side group _killed != playerSide)) case. So when testing in a dedicated server if a player of side West kills a player or AI of side East the code doesn't remove items and magazines from the dead character even if it does so when testing through the editor SP/MP. Share this post Link to post Share on other sites
engima 327 Posted July 7, 2017 What does playerSide return on a dedicated server? There is no player, so the condition does not make sense. A comparison with null in this case will never return true. You should use "side group _killer" and "side group _killed" instead. 1 Share this post Link to post Share on other sites
Asmodeuz 53 Posted July 7, 2017 8 hours ago, engima said: What does playerSide return on a dedicated server? There is no player, so the condition does not make sense. A comparison with null in this case will never return true. You should use "side group _killer" and "side group _killed" instead. Not quite sure that you meant to use them like this _TK = addMissionEventHandler ["EntityKilled", { params["_killed", "_killer", "_instigator"]; if ((side _killer == side group _killer) && (side group _killed == side group _killed)) then { _this = _this select 0; {_this removeMagazine _x} forEach magazines _this; removeAllItems _this; removeAllAssignedItems _this; }; }]; but the code works very well in a mission I have on dedicated server. Thank you for the suggestion @engima! As the code is done it fits every situation except player suicides/respawns. In these cases the code doesn't remove weapon magazines and items! Possible use cases: player kills friendly AI/enemy AI -> weapon magazines and items are removed from the AI friendly AI/enemy AI kills player -> weapon magazines and items are removed from the player Here's a "timed" version of the same code: _TK = addMissionEventHandler ["EntityKilled", { params["_killed", "_killer", "_instigator"]; if ((side _killer == side group _killer) && (side group _killed == side group _killed)) then { (_this select 0) spawn { sleep 10; {_this removeMagazine _x} forEach magazines _this; removeAllItems _this; removeAllAssignedItems _this; }; }; }]; With sleep 10; weapon magazines and items are removed 10 seconds after the unit was killed. Change 10 to something else to better suit your needs. Share this post Link to post Share on other sites