DefenderMoney: add obus' fix back

so what he did was to restore your cash when you kill a zombie as human
This commit is contained in:
dogan 2020-07-30 13:40:41 +02:00
parent 42be4648d6
commit 31c4db3118

View File

@ -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) public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast)
{ {
int client = GetClientOfUserId(hEvent.GetInt("userid")); int client = GetClientOfUserId(hEvent.GetInt("userid"));
int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
g_iCash[client] = GetEntProp(client, Prop_Send, "m_iAccount"); 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; return Plugin_Continue;
} }
@ -232,6 +240,14 @@ public void RequestFrame_Callback(int client)
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[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) stock bool IsValidClient(int client)
{ {
return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client)); return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));