HerrVorragend 10 Posted October 16, 2014 Hi Guys, im trying to give every player money 4 killing a player from another side. Im also trying to remove money from the teamkiller. I added an EventHandler on each player (within the initPlayerLocal.sqf). player addMPEventHandler ["Killed", _this execVM 'playerKilled.sqf';"]; Within the executet script i check if the killer is on the same sideof the victim. _victim = _this select 0; _killer = _this select 1; [format ["%1 killed by %2\n%3 killed by %4",_victim,_killer, (side _victim),(side _killer) ], "systemChat", true] call BIS_fnc_MP; switch (true) do { case ( (_victim) == (_killer) ): {}; // Selfkill via respawn or grenade etc. case ( (side _victim) == (side _killer) ): { // Teamkill _teamKillerVictimMoney = _victim getVariable "Money"; _teamKillerMoney = _killer getVariable "Money"; if( (_teamKillerMoney > 0) && (_teamKillerMoney < SERVER_playerTeamKillMoney) ) then { SERVER_playerTeamKillMoney = _teamKillerMoney; }; _teamKillerMoney = _teamKillerMoney - SERVER_playerTeamKillMoney; _teamKillerVictimMoney = _teamKillerVictimMoney + SERVER_playerTeamKillMoney; _victim setVariable ["Money", _teamKillerVictimMoney, true]; _killer setVariable ["Money", _teamKillerMoney, true]; _killer addRating (0 - (rating _killer)); [format ["Do not kill Teammates!!\n%1 $ have been given to your victim!", SERVER_playerTeamKillMoney], "hint", true] call BIS_fnc_MP; [format ["You received %1 $ from the Teamkiller!", SERVER_playerTeamKillMoney], "hint", true] call BIS_fnc_MP; }; default { // Normal kill _money = _killer getVariable "Money"; _money = _money + SERVER_playerKillMoney; _killer setVariable ["Money", _money, true]; }; }; This doesnt work because the killer is always on CIV side.... But why i dont get it. I use side player very often and it always worked. But not within the eventhandler. Can u tell me why? Share this post Link to post Share on other sites
Naiss 28 Posted October 16, 2014 try this Give_Money = { _p = _this select 0; _amount = 400; Money = Money + _amount; hint format ["%1 You got %2 for killing %3",name player,_amount,name _p]; }; _victim = _this select 0; _killer = _this select 1; [format ["%1 killed by %2\n%3 killed by %4",_victim,_killer, (side _victim),(side _killer) ], "systemChat", true] call BIS_fnc_MP; [_victim, "Give_Money", _Killer] spawn BIS_fnc_MP; switch (true) do { case ( (_victim) == (_killer) ): {}; // Selfkill via respawn or grenade etc. case ( (side _victim) == (side _killer) ): { // Teamkill _teamKillerVictimMoney = _victim getVariable "Money"; _teamKillerMoney = _killer getVariable "Money"; if( (_teamKillerMoney > 0) && (_teamKillerMoney < SERVER_playerTeamKillMoney) ) then { SERVER_playerTeamKillMoney = _teamKillerMoney; }; _teamKillerMoney = _teamKillerMoney - SERVER_playerTeamKillMoney; _teamKillerVictimMoney = _teamKillerVictimMoney + SERVER_playerTeamKillMoney; _victim setVariable ["Money", _teamKillerVictimMoney, true]; _killer setVariable ["Money", _teamKillerMoney, true]; _killer addRating (0 - (rating _killer)); [format ["Do not kill Teammates!!\n%1 $ have been given to your victim!", SERVER_playerTeamKillMoney], "hint", true] call BIS_fnc_MP; [format ["You received %1 $ from the Teamkiller!", SERVER_playerTeamKillMoney], "hint", true] call BIS_fnc_MP; }; default { // Normal kill _money = _killer getVariable "Money"; _money = _money + SERVER_playerKillMoney; _killer setVariable ["Money", _money, true]; }; }; Share this post Link to post Share on other sites
Viba 1 Posted October 16, 2014 Corpses are registered as CIV units, just check the side of the player group. _correctSide = side (group player); Share this post Link to post Share on other sites
dreadedentity 278 Posted October 16, 2014 Corpses are registered as CIV units, just check the side of the player group. Units are removed from their groups after a while after death, unless they respawn back into the same group, so this call should be made relatively soon after a unit's death Share this post Link to post Share on other sites
Viba 1 Posted October 17, 2014 Unless one suspends the script after the EH for a long time, then there's no problems. Share this post Link to post Share on other sites
HerrVorragend 10 Posted October 17, 2014 Corpses are registered as CIV units, just check the side of the player group. _correctSide = side (group player); Wow! i didn't know that!! That solved the probems. What a weird thing.... I search for like hours on the internet. But this forum and his people are the best :-) Thx! Share this post Link to post Share on other sites