DefenderMoney --> CashManager
This commit is contained in:
parent
31c4db3118
commit
c059a49ec7
@ -18,6 +18,8 @@ ConVar g_cvarDamageMultiplier = null;
|
|||||||
|
|
||||||
ConVar g_cvarInfectionGain;
|
ConVar g_cvarInfectionGain;
|
||||||
ConVar g_cvarHumanWinGain;
|
ConVar g_cvarHumanWinGain;
|
||||||
|
ConVar g_cvarRoundStartGain;
|
||||||
|
ConVar g_cvarMaxCash;
|
||||||
|
|
||||||
bool g_bZRLoaded;
|
bool g_bZRLoaded;
|
||||||
bool g_bMapEnd;
|
bool g_bMapEnd;
|
||||||
@ -28,9 +30,9 @@ int g_iSteamID[256];
|
|||||||
|
|
||||||
public Plugin myinfo =
|
public Plugin myinfo =
|
||||||
{
|
{
|
||||||
name = "Defender Money",
|
name = "Cash Manager",
|
||||||
author = "Obus + Dogan",
|
author = "Obus + Dogan",
|
||||||
description = "Reward Humans with cash for shooting Zombies",
|
description = "Manage Cash with additional gains and limits",
|
||||||
version = "1.1.0",
|
version = "1.1.0",
|
||||||
url = ""
|
url = ""
|
||||||
};
|
};
|
||||||
@ -41,14 +43,17 @@ public void OnPluginStart()
|
|||||||
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_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");
|
g_cvarHumanWinGain = CreateConVar("sm_humanwincashgain", "2500", "Cash a human shall receive upon human win");
|
||||||
|
g_cvarRoundStartGain = CreateConVar("sm_roundstartcashgain", "2500", "Cash everyone shall receive upon round start");
|
||||||
|
g_cvarMaxCash = CreateConVar("sm_maxcash", "45000", "Max cash you can store");
|
||||||
|
|
||||||
AutoExecConfig(true, "plugin.DefenderMoney");
|
AutoExecConfig(true, "plugin.CashManager");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
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_Post);
|
HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Post);
|
||||||
|
HookEvent("round_start", EventHook_RoundStart, EventHookMode_Pre);
|
||||||
|
|
||||||
g_bMapEnd = false;
|
g_bMapEnd = false;
|
||||||
}
|
}
|
||||||
@ -111,6 +116,9 @@ public void OnClientPutInServer(int client)
|
|||||||
|
|
||||||
public Action MessageReconnect(Handle timer, int client)
|
public Action MessageReconnect(Handle timer, int client)
|
||||||
{
|
{
|
||||||
|
if(!IsClientInGame(client))
|
||||||
|
return Plugin_Handled;
|
||||||
|
|
||||||
PrintToChat(client, "[SM] Restored your cash: $%d.", g_iCash[client]);
|
PrintToChat(client, "[SM] Restored your cash: $%d.", g_iCash[client]);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -147,7 +155,7 @@ public void OnClientDisconnect(int client)
|
|||||||
|
|
||||||
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, bool respawnOverride, bool respawn)
|
||||||
{
|
{
|
||||||
if(!motherInfect && IsValidClient(attacker))
|
if(!motherInfect && IsValidClient(attacker) && !(GetEntProp(attacker, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
|
||||||
SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue);
|
SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,7 +168,7 @@ public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDo
|
|||||||
if(!IsValidClient(i))
|
if(!IsValidClient(i))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if(ZR_IsClientHuman(i) && bAwardHumans)
|
if(ZR_IsClientHuman(i) && bAwardHumans && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
|
||||||
{
|
{
|
||||||
SetEntProp(i, Prop_Send, "m_iAccount", GetEntProp(i, Prop_Send, "m_iAccount") + g_cvarHumanWinGain.IntValue);
|
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");
|
||||||
@ -172,6 +180,15 @@ public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDo
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Action EventHook_RoundStart(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||||
|
{
|
||||||
|
for(int i = 1; i <= MaxClients; i++)
|
||||||
|
{
|
||||||
|
if(IsValidClient(i) && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
|
||||||
|
g_iCash[i] = g_iCash[i] + g_cvarRoundStartGain.IntValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast)
|
||||||
{
|
{
|
||||||
if(!g_bZRLoaded)
|
if(!g_bZRLoaded)
|
||||||
@ -194,7 +211,7 @@ public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool b
|
|||||||
if(!strncmp(sWeapon, "knife", 5))
|
if(!strncmp(sWeapon, "knife", 5))
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
if(GetEntProp(iAttacker, Prop_Send, "m_iAccount") >= 65000)
|
if(GetEntProp(iAttacker, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)
|
||||||
return Plugin_Continue;
|
return Plugin_Continue;
|
||||||
|
|
||||||
#if defined DMGINSTEADOFHITS
|
#if defined DMGINSTEADOFHITS
|
||||||
@ -236,8 +253,10 @@ public Action EventHook_PlayerSpawn(Event hEvent, const char[] sEventName, bool
|
|||||||
|
|
||||||
public void RequestFrame_Callback(int client)
|
public void RequestFrame_Callback(int client)
|
||||||
{
|
{
|
||||||
if(g_iCash[client] > 0)
|
if(g_iCash[client] > 0 && g_iCash[client] < g_cvarMaxCash.IntValue)
|
||||||
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]);
|
SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]);
|
||||||
|
else if(g_iCash[client] > 0 && g_iCash[client] >= g_cvarMaxCash.IntValue)
|
||||||
|
SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMaxCash.IntValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void RequestFrame_Callback2(int iPacked)
|
public void RequestFrame_Callback2(int iPacked)
|
Loading…
Reference in New Issue
Block a user