DefenderMoney: more fixes and features
This commit is contained in:
parent
d539c84c3e
commit
42be4648d6
@ -16,6 +16,9 @@
|
|||||||
ConVar g_cvarDamageMultiplier = null;
|
ConVar g_cvarDamageMultiplier = null;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
ConVar g_cvarInfectionGain;
|
||||||
|
ConVar g_cvarHumanWinGain;
|
||||||
|
|
||||||
bool g_bZRLoaded;
|
bool g_bZRLoaded;
|
||||||
bool g_bMapEnd;
|
bool g_bMapEnd;
|
||||||
|
|
||||||
@ -36,6 +39,8 @@ public void OnPluginStart()
|
|||||||
{
|
{
|
||||||
#if defined DMGINSTEADOFHITS
|
#if defined DMGINSTEADOFHITS
|
||||||
g_cvarDamageMultiplier = CreateConVar("sm_damagecashmultiplier", "1.0", "Multiplier that decides how much cash a client shall receive upon dealing damage");
|
g_cvarDamageMultiplier = CreateConVar("sm_damagecashmultiplier", "1.0", "Multiplier that decides how much cash a client shall receive upon dealing damage");
|
||||||
|
g_cvarInfectionGain = CreateConVar("sm_infectioncashgain", "500", "Cash a client shall receive upon infection");
|
||||||
|
g_cvarHumanWinGain = CreateConVar("sm_humanwincashgain", "2500", "Cash a human shall receive upon human win");
|
||||||
|
|
||||||
AutoExecConfig(true, "plugin.DefenderMoney");
|
AutoExecConfig(true, "plugin.DefenderMoney");
|
||||||
#endif
|
#endif
|
||||||
@ -43,7 +48,7 @@ public void OnPluginStart()
|
|||||||
HookEvent("player_hurt", EventHook_PlayerHurt, EventHookMode_Pre);
|
HookEvent("player_hurt", EventHook_PlayerHurt, EventHookMode_Pre);
|
||||||
HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre);
|
HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre);
|
||||||
HookEvent("player_spawn", EventHook_PlayerSpawn, EventHookMode_Post);
|
HookEvent("player_spawn", EventHook_PlayerSpawn, EventHookMode_Post);
|
||||||
HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Pre);
|
HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Post);
|
||||||
|
|
||||||
g_bMapEnd = false;
|
g_bMapEnd = false;
|
||||||
}
|
}
|
||||||
@ -113,7 +118,7 @@ public Action MessageReconnect(Handle timer, int client)
|
|||||||
|
|
||||||
public void OnClientDisconnect(int client)
|
public void OnClientDisconnect(int client)
|
||||||
{
|
{
|
||||||
if(IsFakeClient(client))
|
if(IsFakeClient(client) || !IsClientInGame(client))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
int iSteamID = GetSteamAccountID(client);
|
int iSteamID = GetSteamAccountID(client);
|
||||||
@ -140,13 +145,31 @@ public void OnClientDisconnect(int client)
|
|||||||
g_iCash[client] = 0;
|
g_iCash[client] = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||||
|
{
|
||||||
|
if(!motherInfect && IsValidClient(attacker))
|
||||||
|
SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue);
|
||||||
|
}
|
||||||
|
|
||||||
public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||||
{
|
{
|
||||||
|
bool bAwardHumans = hEvent.GetInt("winner") == CS_TEAM_CT;
|
||||||
|
|
||||||
for(int i = 1; i <= MaxClients; i++)
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
{
|
{
|
||||||
if(IsValidClient(i))
|
if(!IsValidClient(i))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if(ZR_IsClientHuman(i) && bAwardHumans)
|
||||||
|
{
|
||||||
|
SetEntProp(i, Prop_Send, "m_iAccount", GetEntProp(i, Prop_Send, "m_iAccount") + g_cvarHumanWinGain.IntValue);
|
||||||
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
|
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||||
@ -198,12 +221,17 @@ public Action EventHook_PlayerSpawn(Event hEvent, const char[] sEventName, bool
|
|||||||
{
|
{
|
||||||
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
||||||
|
|
||||||
if(g_iCash[client] > 0)
|
RequestFrame(RequestFrame_Callback, client);
|
||||||
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]);
|
|
||||||
|
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void RequestFrame_Callback(int client)
|
||||||
|
{
|
||||||
|
if(g_iCash[client] > 0)
|
||||||
|
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]);
|
||||||
|
}
|
||||||
|
|
||||||
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));
|
||||||
|
Loading…
Reference in New Issue
Block a user