From 31c4db31187122d492e6496b612853fc409e2af3 Mon Sep 17 00:00:00 2001 From: dogan Date: Thu, 30 Jul 2020 13:40:41 +0200 Subject: [PATCH] DefenderMoney: add obus' fix back so what he did was to restore your cash when you kill a zombie as human --- _DefenderMoney/scripting/DefenderMoney.sp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/_DefenderMoney/scripting/DefenderMoney.sp b/_DefenderMoney/scripting/DefenderMoney.sp index da7a042e..a48b2ccb 100644 --- a/_DefenderMoney/scripting/DefenderMoney.sp +++ b/_DefenderMoney/scripting/DefenderMoney.sp @@ -211,9 +211,17 @@ public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool b public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast) { int client = GetClientOfUserId(hEvent.GetInt("userid")); + int attacker = GetClientOfUserId(hEvent.GetInt("attacker")); g_iCash[client] = GetEntProp(client, Prop_Send, "m_iAccount"); + if (!IsValidClient(attacker) || !ZR_IsClientHuman(attacker)) + return Plugin_Continue; + + int iPacked = (attacker<<16) | (GetEntProp(attacker, Prop_Send, "m_iAccount")&0xFFFF); + + RequestFrame(RequestFrame_Callback2, iPacked); + return Plugin_Continue; } @@ -232,6 +240,14 @@ public void RequestFrame_Callback(int client) SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]); } +public void RequestFrame_Callback2(int iPacked) +{ + int iOldCash = iPacked&0xFFFF; + int iAttacker = iPacked>>16; + + SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash); +} + stock bool IsValidClient(int client) { return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));