CashManager: more stuff

This commit is contained in:
dogan 2020-08-23 00:28:58 +02:00
parent bd5e2eb1c1
commit 76669c1cb1

View File

@ -24,13 +24,16 @@ ConVar g_cvarMotherZombieWinGain;
ConVar g_cvarHumanWinGain; ConVar g_cvarHumanWinGain;
ConVar g_cvarHumanTriggerGain; ConVar g_cvarHumanTriggerGain;
ConVar g_cvarRoundStartCash; ConVar g_cvarRoundStartCash;
ConVar g_cvarMapStartCash; ConVar g_cvarStartCash;
ConVar g_cvarMaxCash; ConVar g_cvarMaxCash;
ConVar g_cvarCashRoundReset;
bool g_bZRLoaded; bool g_bZRLoaded;
bool g_bMapEnd; bool g_bMapEnd;
bool g_bTriggerCooldown; bool g_bTriggerCooldown;
bool g_bDisabled[2048]; bool g_bDisabled[2048];
bool g_bAwardHumans;
bool g_bAwardZombies;
bool g_bMotherZombie[MAXPLAYERS + 1]; bool g_bMotherZombie[MAXPLAYERS + 1];
@ -43,7 +46,7 @@ public Plugin myinfo =
name = "Cash Manager", name = "Cash Manager",
author = "Obus + Dogan", author = "Obus + Dogan",
description = "Manage Cash with additional gains and limits", description = "Manage Cash with additional gains and limits",
version = "2.0.0", version = "3.0.0",
url = "" url = ""
}; };
@ -51,13 +54,14 @@ 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_cvarInfectionGain = CreateConVar("sm_infectioncashgain", "500", "Cash a client shall receive upon infection [Dependency: sm_cashroundreset]");
g_cvarMotherZombieWinGain = CreateConVar("sm_motherzombiecashgain", "2500", "Cash a client shall receive upon zombie win while being motherzombie"); g_cvarMotherZombieWinGain = CreateConVar("sm_motherzombiecashgain", "2500", "Cash a client shall receive upon zombie win while being motherzombie [Dependency: sm_cashroundreset]");
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 [Dependency: sm_cashroundreset]");
g_cvarHumanTriggerGain = CreateConVar("sm_humantriggercashgain", "200", "Cash a human shall receive upon triggering"); g_cvarHumanTriggerGain = CreateConVar("sm_humantriggercashgain", "200", "Cash a human shall receive upon triggering");
g_cvarRoundStartCash = CreateConVar("sm_roundstartcash", "2500", "Minimum cash a client starts the round"); g_cvarRoundStartCash = CreateConVar("sm_roundstartcash", "2500", "Minimum cash a client starts the round [Dependency: sm_cashroundreset]");
g_cvarMapStartCash = CreateConVar("sm_mapstartcash", "12500", "Cash a client starts the map"); g_cvarStartCash = CreateConVar("sm_startcash", "12500", "Cash a client starts the map or round [for round Dependency: sm_cashroundreset]");
g_cvarMaxCash = CreateConVar("sm_maxcash", "45000", "Max cash you can store"); g_cvarMaxCash = CreateConVar("sm_maxcash", "45000", "Max cash you can store");
g_cvarCashRoundReset = CreateConVar("sm_cashroundreset", "0", "1 = CashManager resets the cash each round, 0 = CashManager doesn't reset the cash at all during a map", FCVAR_NONE, true, 0.0, true, 1.0);
AutoExecConfig(true, "plugin.CashManager"); AutoExecConfig(true, "plugin.CashManager");
#endif #endif
@ -112,13 +116,13 @@ public void OnMapEnd()
public void OnClientPutInServer(int client) public void OnClientPutInServer(int client)
{ {
if(IsFakeClient(client) || g_bMapEnd) if(IsFakeClient(client) || g_bMapEnd || g_cvarCashRoundReset.BoolValue)
return; return;
int iSteamID = GetSteamAccountID(client); int iSteamID = GetSteamAccountID(client);
g_iCash[client] = g_cvarMapStartCash.IntValue; g_iCash[client] = g_cvarStartCash.IntValue;
SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMapStartCash.IntValue); SetEntProp(client, Prop_Send, "m_iAccount", g_cvarStartCash.IntValue);
for(int i = 0; i < 256; i++) for(int i = 0; i < 256; i++)
{ {
@ -144,7 +148,7 @@ public Action MessageReconnect(Handle timer, int client)
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
if(IsFakeClient(client) || !IsClientInGame(client)) if(IsFakeClient(client) || !IsClientInGame(client) || g_cvarCashRoundReset.BoolValue)
return; return;
int iSteamID = GetSteamAccountID(client); int iSteamID = GetSteamAccountID(client);
@ -174,12 +178,15 @@ 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(g_cvarCashRoundReset.BoolValue)
return;
g_bMotherZombie[client] = motherInfect; g_bMotherZombie[client] = motherInfect;
if(!motherInfect && IsValidClient(attacker) && !(GetEntProp(attacker, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) 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);
CPrintToChat(attacker, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for infecting an Human.", g_cvarInfectionGain.IntValue); CPrintToChat(attacker, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for infecting an Human.", g_cvarInfectionGain.IntValue);
} }
} }
@ -204,7 +211,7 @@ public void OnStartTouch(const char[] sOutput, int iCaller, int iActivator, floa
if(!(GetEntProp(iActivator, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) if(!(GetEntProp(iActivator, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
{ {
SetEntProp(iActivator, Prop_Send, "m_iAccount", GetEntProp(iActivator, Prop_Send, "m_iAccount") + g_cvarHumanTriggerGain.IntValue); SetEntProp(iActivator, Prop_Send, "m_iAccount", GetEntProp(iActivator, Prop_Send, "m_iAccount") + g_cvarHumanTriggerGain.IntValue);
CPrintToChat(iActivator, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for getting a Trigger.", g_cvarHumanTriggerGain.IntValue); CPrintToChat(iActivator, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for getting a Trigger.", g_cvarHumanTriggerGain.IntValue);
} }
} }
@ -239,7 +246,7 @@ public void OnPressed(const char[] sOutput, int iCaller, int iActivator, float f
if(!(GetEntProp(iActivator, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) if(!(GetEntProp(iActivator, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
{ {
SetEntProp(iActivator, Prop_Send, "m_iAccount", GetEntProp(iActivator, Prop_Send, "m_iAccount") + g_cvarHumanTriggerGain.IntValue); SetEntProp(iActivator, Prop_Send, "m_iAccount", GetEntProp(iActivator, Prop_Send, "m_iAccount") + g_cvarHumanTriggerGain.IntValue);
CPrintToChat(iActivator, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for getting a Trigger.", g_cvarHumanTriggerGain.IntValue); CPrintToChat(iActivator, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for getting a Trigger.", g_cvarHumanTriggerGain.IntValue);
} }
} }
@ -250,31 +257,15 @@ public Action ResetTriggerCD(Handle timer)
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); if(g_cvarCashRoundReset.BoolValue)
bool bAwardZombies = (hEvent.GetInt("winner") == CS_TEAM_T); return Plugin_Handled;
for(int i = 1; i <= MaxClients; i++) g_bAwardHumans = (hEvent.GetInt("winner") == CS_TEAM_CT);
{ g_bAwardZombies = (hEvent.GetInt("winner") == CS_TEAM_T);
if(!IsValidClient(i))
continue;
if(GetClientTeam(i) == CS_TEAM_CT && bAwardHumans && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) RequestFrame(RequestFrame_Callback3);
{
SetEntProp(i, Prop_Send, "m_iAccount", GetEntProp(i, Prop_Send, "m_iAccount") + g_cvarHumanWinGain.IntValue); return Plugin_Handled;
CPrintToChat(i, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for winning as Human.", g_cvarHumanWinGain.IntValue);
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
else if(GetClientTeam(i) == CS_TEAM_T && bAwardZombies && g_bMotherZombie[i] && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
{
SetEntProp(i, Prop_Send, "m_iAccount", GetEntProp(i, Prop_Send, "m_iAccount") + g_cvarMotherZombieWinGain.IntValue);
CPrintToChat(i, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for winning as MotherZombie.", g_cvarMotherZombieWinGain.IntValue);
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
else
{
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
}
} }
public Action EventHook_RoundStart(Event hEvent, const char[] sEventName, bool bDontBroadcast) public Action EventHook_RoundStart(Event hEvent, const char[] sEventName, bool bDontBroadcast)
@ -327,22 +318,25 @@ public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool
int client = GetClientOfUserId(hEvent.GetInt("userid")); int client = GetClientOfUserId(hEvent.GetInt("userid"));
int attacker = GetClientOfUserId(hEvent.GetInt("attacker")); int attacker = GetClientOfUserId(hEvent.GetInt("attacker"));
g_iCash[client] = GetEntProp(client, Prop_Send, "m_iAccount"); if(!g_cvarCashRoundReset.BoolValue)
char sWeapon[16];
hEvent.GetString("weapon", sWeapon, sizeof(sWeapon));
if(!IsValidClient(attacker))
return Plugin_Continue;
if(ZR_IsClientZombie(attacker) && StrEqual(sWeapon, "knife", true) && !(GetEntProp(attacker, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) //nemesis kill
{ {
SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue); g_iCash[client] = GetEntProp(client, Prop_Send, "m_iAccount");
CPrintToChat(attacker, "{cyan}[UNLOZE CashManager] {white}Gained {yellow}$%d{white} for killing an Human.", g_cvarInfectionGain.IntValue);
} char sWeapon[16];
else if(ZR_IsClientZombie(attacker)) // regular infection hEvent.GetString("weapon", sWeapon, sizeof(sWeapon));
{
return Plugin_Continue; if(!IsValidClient(attacker))
return Plugin_Continue;
if(ZR_IsClientZombie(attacker) && StrEqual(sWeapon, "knife", true) && !(GetEntProp(attacker, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) //nemesis kill
{
SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue);
CPrintToChat(attacker, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for killing an Human.", g_cvarInfectionGain.IntValue);
}
else if(ZR_IsClientZombie(attacker)) // regular infection
{
return Plugin_Continue;
}
} }
int iPacked = (attacker<<16) | (GetEntProp(attacker, Prop_Send, "m_iAccount")&0xFFFF); int iPacked = (attacker<<16) | (GetEntProp(attacker, Prop_Send, "m_iAccount")&0xFFFF);
@ -363,12 +357,21 @@ public Action EventHook_PlayerSpawn(Event hEvent, const char[] sEventName, bool
public void RequestFrame_Callback(int client) public void RequestFrame_Callback(int client)
{ {
if(g_cvarCashRoundReset.BoolValue)
{
SetEntProp(client, Prop_Send, "m_iAccount", g_cvarStartCash.IntValue);
CPrintToChat(client, "{cyan}[UNLOZE CashManager] {white}Resetting your Cash to {yellow}$%d{white}.", g_cvarStartCash.IntValue);
return;
}
if(g_iCash[client] >= 0 && g_iCash[client] < g_cvarRoundStartCash.IntValue) //Player is (almost) broke if(g_iCash[client] >= 0 && g_iCash[client] < g_cvarRoundStartCash.IntValue) //Player is (almost) broke
SetEntProp(client, Prop_Send, "m_iAccount", g_cvarRoundStartCash.IntValue); SetEntProp(client, Prop_Send, "m_iAccount", g_cvarRoundStartCash.IntValue);
else if(g_iCash[client] >= 0 && g_iCash[client] < g_cvarMaxCash.IntValue) //Player isn't broke else if(g_iCash[client] >= 0 && g_iCash[client] < g_cvarMaxCash.IntValue) //Player isn't broke
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) //Player hit limit else if(g_iCash[client] >= 0 && g_iCash[client] >= g_cvarMaxCash.IntValue) //Player hit limit
SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMaxCash.IntValue); SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMaxCash.IntValue);
return;
} }
public void RequestFrame_Callback2(int iPacked) public void RequestFrame_Callback2(int iPacked)
@ -379,6 +382,32 @@ public void RequestFrame_Callback2(int iPacked)
SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash); SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash);
} }
public void RequestFrame_Callback3()
{
for(int i = 1; i <= MaxClients; i++)
{
if(!IsClientInGame(i))
continue;
if(IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_CT && g_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);
CPrintToChat(i, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for winning as Human.", g_cvarHumanWinGain.IntValue);
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
else if(IsPlayerAlive(i) && GetClientTeam(i) == CS_TEAM_T && g_bAwardZombies && g_bMotherZombie[i] && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue))
{
SetEntProp(i, Prop_Send, "m_iAccount", GetEntProp(i, Prop_Send, "m_iAccount") + g_cvarMotherZombieWinGain.IntValue);
CPrintToChat(i, "{cyan}[UNLOZE CashManager] {white}You gained {yellow}$%d{white} for winning as MotherZombie.", g_cvarMotherZombieWinGain.IntValue);
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
else
{
g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount");
}
}
}
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));