From 1b186c3ea5d4f698101f7fd909229f01c1408415 Mon Sep 17 00:00:00 2001 From: dogan Date: Sun, 16 Aug 2020 22:12:53 +0200 Subject: [PATCH] BossHP: more shekels + CashManager: couple changes --- BossHP/scripting/BossHP_Ranking.sp | 2 +- CashManager/scripting/CashManager.sp | 107 ++++++++++++++++++++++----- 2 files changed, 91 insertions(+), 18 deletions(-) diff --git a/BossHP/scripting/BossHP_Ranking.sp b/BossHP/scripting/BossHP_Ranking.sp index 17ec059a..349b9b43 100644 --- a/BossHP/scripting/BossHP_Ranking.sp +++ b/BossHP/scripting/BossHP_Ranking.sp @@ -84,7 +84,7 @@ public void OnBossDamaged(CBoss Boss, CConfig Config, int client, float damage) if (!IsValidClient(client)) return; - SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") + 1); + SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") + 2); bool bBreakable; CConfig _Config = view_as(Config); diff --git a/CashManager/scripting/CashManager.sp b/CashManager/scripting/CashManager.sp index 50e6c7fd..11fa9465 100644 --- a/CashManager/scripting/CashManager.sp +++ b/CashManager/scripting/CashManager.sp @@ -2,6 +2,8 @@ #include #include +#include +#include #undef REQUIRE_PLUGIN #tryinclude @@ -19,11 +21,15 @@ ConVar g_cvarDamageMultiplier = null; ConVar g_cvarInfectionGain; ConVar g_cvarMotherZombieWinGain; ConVar g_cvarHumanWinGain; -ConVar g_cvarRoundStartGain; +ConVar g_cvarHumanTriggerGain; +ConVar g_cvarRoundStartCash; +ConVar g_cvarMapStartCash; ConVar g_cvarMaxCash; bool g_bZRLoaded; bool g_bMapEnd; +bool g_bTriggerCooldown; +bool g_bDisabled[2048]; bool g_bMotherZombie[MAXPLAYERS + 1]; @@ -47,7 +53,9 @@ public void OnPluginStart() g_cvarInfectionGain = CreateConVar("sm_infectioncashgain", "500", "Cash a client shall receive upon infection"); g_cvarMotherZombieWinGain = CreateConVar("sm_motherzombiecashgain", "2500", "Cash a client shall receive upon zombie win while being motherzombie"); 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_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_cvarMapStartCash = CreateConVar("sm_mapstartcash", "12500", "Cash a client starts the map"); g_cvarMaxCash = CreateConVar("sm_maxcash", "45000", "Max cash you can store"); AutoExecConfig(true, "plugin.CashManager"); @@ -57,7 +65,10 @@ public void OnPluginStart() HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre); HookEvent("player_spawn", EventHook_PlayerSpawn, EventHookMode_Post); HookEvent("round_end", EventHook_RoundEnd, EventHookMode_Post); - HookEvent("round_start", EventHook_RoundStart, EventHookMode_Pre); + HookEvent("round_start", EventHook_RoundStart, EventHookMode_Post); + + HookEntityOutput("trigger_once", "OnStartTouch", OnStartTouch); + HookEntityOutput("func_button", "OnPressed", OnPressed); g_bMapEnd = false; } @@ -84,13 +95,11 @@ public void OnMapStart() for(int i = 0; i < 256; i++) { g_iSteamID[i] = 0; - g_iCashReconnect[i] = 0; + g_iCashReconnect[i] = -1; } for(int i = 1; i <= MaxClients; i++) - { - g_iCash[i] = 0; - } + g_iCash[i] = -1; g_bMapEnd = false; } @@ -105,15 +114,17 @@ public void OnClientPutInServer(int client) if(IsFakeClient(client) || g_bMapEnd) return; - g_iCash[client] = 16000 - g_cvarRoundStartGain.IntValue; - int iSteamID = GetSteamAccountID(client); + g_iCash[client] = g_cvarMapStartCash.IntValue; + SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMapStartCash.IntValue); + for(int i = 0; i < 256; i++) { if(iSteamID == g_iSteamID[i]) { g_iCash[client] = g_iCashReconnect[i]; + SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]); CreateTimer(3.0, MessageReconnect, client); break; } @@ -156,7 +167,7 @@ public void OnClientDisconnect(int client) } } - g_iCash[client] = 0; + g_iCash[client] = -1; g_bMotherZombie[client] = false; } @@ -168,6 +179,65 @@ public void ZR_OnClientInfected(int client, int attacker, bool motherInfect, boo SetEntProp(attacker, Prop_Send, "m_iAccount", GetEntProp(attacker, Prop_Send, "m_iAccount") + g_cvarInfectionGain.IntValue); } +public void OnStartTouch(const char[] sOutput, int iCaller, int iActivator, float fDelay) +{ + if (!IsValidClient(iActivator)) + return; + + if (g_bDisabled[iCaller] || g_bTriggerCooldown) + return; + + if (!(ZR_IsClientHuman(iActivator))) + return; + + g_bDisabled[iCaller] = true; + g_bTriggerCooldown = true; + + float fTriggerCD = GetConVarFloat(FindConVar("sm_trigger_reward_cd")); + + CreateTimer(fTriggerCD, ResetTriggerCD); + + 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); +} + +public void OnPressed(const char[] sOutput, int iCaller, int iActivator, float fDelay) +{ + if(!IsValidClient(iActivator)) + return; + + if (g_bDisabled[iCaller] || g_bTriggerCooldown) + return; + + if (!(ZR_IsClientHuman(iActivator))) + return; + + int iParent = INVALID_ENT_REFERENCE; + if ((iParent = GetEntPropEnt(iCaller, Prop_Data, "m_hMoveParent")) != INVALID_ENT_REFERENCE) + { + char sClassname[64]; + GetEdictClassname(iParent, sClassname, sizeof(sClassname)); + + if (strncmp(sClassname, "weapon_", 7, false) == 0) + return; + } + + g_bDisabled[iCaller] = true; + g_bTriggerCooldown= true; + + float fTriggerCD = GetConVarFloat(FindConVar("sm_trigger_reward_cd")); + + CreateTimer(fTriggerCD, ResetTriggerCD); + + 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); +} + +public Action ResetTriggerCD(Handle timer) +{ + g_bTriggerCooldown = false; +} + public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDontBroadcast) { bool bAwardHumans = (hEvent.GetInt("winner") == CS_TEAM_CT); @@ -178,12 +248,15 @@ public Action EventHook_RoundEnd(Event hEvent, const char[] sEventName, bool bDo if(!IsValidClient(i)) continue; + if(g_iCash[i] == -1) + continue; + if(GetClientTeam(i) == CS_TEAM_CT && 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); g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount"); } - if(GetClientTeam(i) == CS_TEAM_T && bAwardZombies && g_bMotherZombie[i] && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) + 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); g_iCash[i] = GetEntProp(i, Prop_Send, "m_iAccount"); @@ -198,12 +271,10 @@ 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++) - { g_bMotherZombie[i] = false; - if(IsValidClient(i) && !(GetEntProp(i, Prop_Send, "m_iAccount") >= g_cvarMaxCash.IntValue)) - g_iCash[i] = g_iCash[i] + g_cvarRoundStartGain.IntValue; - } + for(int i = 0; i < 2048; i++) + g_bDisabled[i] = false; } public Action EventHook_PlayerHurt(Event hEvent, const char[] sEventName, bool bDontBroadcast) @@ -278,9 +349,11 @@ public Action EventHook_PlayerSpawn(Event hEvent, const char[] sEventName, bool public void RequestFrame_Callback(int client) { - if(g_iCash[client] > 0 && g_iCash[client] < g_cvarMaxCash.IntValue) + if(g_iCash[client] >= 0 && g_iCash[client] < g_cvarRoundStartCash.IntValue) //Player is (almost) broke + 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 SetEntProp(client, Prop_Send, "m_iAccount", g_iCash[client]); - else if(g_iCash[client] > 0 && g_iCash[client] >= g_cvarMaxCash.IntValue) + else if(g_iCash[client] >= 0 && g_iCash[client] >= g_cvarMaxCash.IntValue) //Player hit limit SetEntProp(client, Prop_Send, "m_iAccount", g_cvarMaxCash.IntValue); }