From 3f24a84eca13991a9c4bf51c09c1eaa464175d3b Mon Sep 17 00:00:00 2001 From: neon <> Date: Mon, 12 Nov 2018 17:27:46 +0100 Subject: [PATCH] BossHP_Ranking: cash can exceed 16k now --- BossHP/scripting/BossHP_Ranking.sp | 70 ++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 3 deletions(-) diff --git a/BossHP/scripting/BossHP_Ranking.sp b/BossHP/scripting/BossHP_Ranking.sp index d72eb2d6..bcfe98f0 100644 --- a/BossHP/scripting/BossHP_Ranking.sp +++ b/BossHP/scripting/BossHP_Ranking.sp @@ -1,5 +1,6 @@ #include #include +#include #include "loghelper.inc" @@ -9,6 +10,8 @@ ArrayList g_hStats[MAXPLAYERS+1]; +bool g_bZRLoaded; + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -25,6 +28,8 @@ public Plugin myinfo = //---------------------------------------------------------------------------------------------------- public void OnPluginStart() { + HookEvent("player_death", EventHook_PlayerDeath, EventHookMode_Pre); + for (int client = 1; client <= MaxClients; client++) { if (!IsClientInGame(client)) @@ -34,6 +39,32 @@ public void OnPluginStart() } } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnAllPluginsLoaded() +{ + g_bZRLoaded = LibraryExists("zombiereloaded"); +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnLibraryAdded(const char[] sName) +{ + if (strcmp(sName, "zombiereloaded", false) == 0) + g_bZRLoaded = true; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public void OnLibraryRemoved(const char[] sName) +{ + if (strcmp(sName, "zombiereloaded", false) == 0) + g_bZRLoaded = false; +} + //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- @@ -58,10 +89,12 @@ public void OnBossDamaged(any Boss, any Config, int client) if (!IsValidClient(client)) return; - int iCurrentCash = GetEntProp(client, Prop_Send, "m_iAccount"); + //int iCurrentCash = GetEntProp(client, Prop_Send, "m_iAccount"); - if (iCurrentCash < 16000) - SetEntProp(client, Prop_Send, "m_iAccount", iCurrentCash + 1); + //if (iCurrentCash < 16000) + // SetEntProp(client, Prop_Send, "m_iAccount", iCurrentCash + 1); + + SetEntProp(client, Prop_Send, "m_iAccount", GetEntProp(client, Prop_Send, "m_iAccount") + 1); for (int index = 0; index < g_hStats[client].Length; index++) { @@ -228,6 +261,37 @@ public void OnBossKilled(any Boss, any Config, int reason) } } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public Action EventHook_PlayerDeath(Event hEvent, const char[] sEventName, bool bDontBroadcast) +{ + if (!g_bZRLoaded) + return Plugin_Continue; + + 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); + + return Plugin_Continue; +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +void RequestFrame_Callback(int iPacked) +{ + int iOldCash = iPacked&0xFFFF; + int iAttacker = iPacked>>16; + + SetEntProp(iAttacker, Prop_Send, "m_iAccount", iOldCash); +} + //---------------------------------------------------------------------------------------------------- // Purpose: //----------------------------------------------------------------------------------------------------