DefenderMoney: lets try dis
This commit is contained in:
parent
7aa30d98ed
commit
65fe0f846b
@ -18,12 +18,14 @@ ConVar g_cvarDamageMultiplier = null;
|
||||
|
||||
bool g_bZRLoaded;
|
||||
|
||||
int g_iCash[MAXPLAYERS + 1];
|
||||
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "Defender Money",
|
||||
author = "Obus",
|
||||
author = "Obus + Dogan",
|
||||
description = "",
|
||||
version = "0.0.1",
|
||||
version = "1.0.0",
|
||||
url = ""
|
||||
};
|
||||
|
||||
@ -37,6 +39,8 @@ public void OnPluginStart()
|
||||
|
||||
HookEvent("player_hurt", EventHook_PlayerHurt, EventHookMode_Pre);
|
||||
HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre);
|
||||
HookEvent("player_spawn", EventHook_PlayerSpawn, EventHookMode_Post);
|
||||
HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Pre);
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
@ -46,36 +50,61 @@ public void OnAllPluginsLoaded()
|
||||
|
||||
public void OnLibraryAdded(const char[] sName)
|
||||
{
|
||||
if (strcmp(sName, "zombiereloaded", false) == 0)
|
||||
if(strcmp(sName, "zombiereloaded", false) == 0)
|
||||
g_bZRLoaded = true;
|
||||
}
|
||||
|
||||
public void OnLibraryRemoved(const char[] sName)
|
||||
{
|
||||
if (strcmp(sName, "zombiereloaded", false) == 0)
|
||||
if(strcmp(sName, "zombiereloaded", false) == 0)
|
||||
g_bZRLoaded = false;
|
||||
}
|
||||
|
||||
public void OnMapStart()
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
g_iCash[i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_iCash[client] = 0;
|
||||
}
|
||||
|
||||
public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||
{
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsValidClient(i))
|
||||
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
|
||||
}
|
||||
}
|
||||
|
||||
public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||
{
|
||||
if (!g_bZRLoaded)
|
||||
if(!g_bZRLoaded)
|
||||
return Plugin_Continue;
|
||||
|
||||
int iAttacker = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
|
||||
if (!IsValidClient(iAttacker) || !ZR_IsClientHuman(iAttacker))
|
||||
if(!IsValidClient(iAttacker) || !ZR_IsClientHuman(iAttacker))
|
||||
return Plugin_Continue;
|
||||
|
||||
int iVictim = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
if (!IsValidClient(iVictim) || !ZR_IsClientZombie(iVictim))
|
||||
if(!IsValidClient(iVictim) || !ZR_IsClientZombie(iVictim))
|
||||
return Plugin_Continue;
|
||||
|
||||
char sWeapon[16];
|
||||
|
||||
hEvent.GetString("weapon", sWeapon, sizeof(sWeapon));
|
||||
|
||||
if (!strncmp(sWeapon, "knife", 5))
|
||||
if(!strncmp(sWeapon, "knife", 5))
|
||||
return Plugin_Continue;
|
||||
|
||||
if(GetEntProp(iAttacker, Prop_Send, "m_iAccount") >= 65000)
|
||||
return Plugin_Continue;
|
||||
|
||||
#if defined DMGINSTEADOFHITS
|
||||
@ -91,30 +120,24 @@ public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool b
|
||||
|
||||
public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||
{
|
||||
if (!g_bZRLoaded)
|
||||
return Plugin_Continue;
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
int iAttacker = GetClientOfUserId(hEvent.GetInt("attacker"));
|
||||
|
||||
if (!IsValidClient(iAttacker) || !ZR_IsClientHuman(iAttacker))
|
||||
return Plugin_Continue;
|
||||
|
||||
int iPacked = (iAttacker<<16) | (GetEntProp(iAttacker, Prop_Send, "m_iAccount")&0xFFFF);
|
||||
|
||||
RequestFrame(RequestFrame_Callback, iPacked);
|
||||
g_iCash[client] = GetEntProp(client, Prop_Send, "m_iAccount");
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
void RequestFrame_Callback(int iPacked)
|
||||
public Action EventHook_PlayerSpawn(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||
{
|
||||
int iOldCash = iPacked&0xFFFF;
|
||||
int iAttacker = iPacked>>16;
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||
|
||||
SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash);
|
||||
if(g_iCash[client] > 0)
|
||||
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]);
|
||||
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
stock bool IsValidClient(int client)
|
||||
{
|
||||
return (client > 0 && client <= MaxClients && IsClientInGame(client) && IsPlayerAlive(client));
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user