diff --git a/src/zr/playerclasses/clientoverlays.inc b/src/zr/playerclasses/clientoverlays.inc index 47a56aa..97f7a87 100644 --- a/src/zr/playerclasses/clientoverlays.inc +++ b/src/zr/playerclasses/clientoverlays.inc @@ -155,6 +155,12 @@ ClassOverlayInitialize(client, const String:overlay[]) */ public Action:ClassOverlayEnableCommand(client, argc) { + // If client isn't valid, then stop. + if (!ZRIsClientValid(client)) + { + return; + } + // If overlay toggle is disabled, then stop. new bool:overlaytoggle = GetConVarBool(g_hCvarsList[CVAR_CLASSES_OVERLAY_TOGGLE]); if (!overlaytoggle) diff --git a/src/zr/weapons/restrict.inc b/src/zr/weapons/restrict.inc index 71d2886..3e963c9 100644 --- a/src/zr/weapons/restrict.inc +++ b/src/zr/weapons/restrict.inc @@ -246,8 +246,14 @@ RestrictOnRoundEnd() */ public Action:RestrictBuyCommand(client, argc) { - // If client isn't in-game, then stop. - if (!IsClientInGame(client)) + // If client isn't valid, then stop. + if (!ZRIsClientValid(client)) + { + return Plugin_Continue; + } + + // If the client isn't in a buyzone, then stop. + if (!WeaponsIsClientInBuyZone(client)) { return Plugin_Continue; } diff --git a/src/zr/weapons/weapons.inc b/src/zr/weapons/weapons.inc index dbb6a95..015afb4 100644 --- a/src/zr/weapons/weapons.inc +++ b/src/zr/weapons/weapons.inc @@ -127,9 +127,15 @@ WeaponsOnOffsetsFound() LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CBasePlayer::m_hActiveWeapon\" was not found."); } + // If offset "m_bInBuyZone" can't be found, then stop the plugin. + g_iToolsInBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone"); + if (g_iToolsInBuyZone == -1) + { + LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CCSPlayer::m_bInBuyZone\" was not found."); + } + // Forward event to sub-modules WeaponAmmoOnOffsetsFound(); - ZMarketOnOffsetsFound(); } /** @@ -906,3 +912,14 @@ stock WeaponsRefreshAllClientWeapons(client) WeaponsRefreshClientWeapon(client, WeaponsSlot:x); } } + +/** + * Checks if a client is in a buyzone. + * + * @param client The client index. + */ +stock bool:WeaponsIsClientInBuyZone(client) +{ + // Return if client is in buyzone. + return bool:GetEntData(client, g_iToolsInBuyZone); +} diff --git a/src/zr/weapons/zmarket.inc b/src/zr/weapons/zmarket.inc index 7818959..7888ab4 100644 --- a/src/zr/weapons/zmarket.inc +++ b/src/zr/weapons/zmarket.inc @@ -94,19 +94,6 @@ ZMarketOnCookiesCreate() } } -/** - * Find ZMarket-specific offsets here. - */ -ZMarketOnOffsetsFound() -{ - // If offset "m_bInBuyZone" can't be found, then stop the plugin. - g_iToolsInBuyZone = FindSendPropInfo("CCSPlayer", "m_bInBuyZone"); - if (g_iToolsInBuyZone == -1) - { - LogEvent(false, LogType_Fatal, LOG_CORE_EVENTS, LogModule_Weapons, "Offsets", "Offset \"CCSPlayer::m_bInBuyZone\" was not found."); - } -} - /** * Client is joining the server. * @@ -786,7 +773,7 @@ stock bool:ZMarketEquip(client, const String:weapon[], bool:rebuy = false) } new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]); - if (!rebuy && zmarketbuyzone && !ZMarketIsClientInBuyZone(client)) + if (!rebuy && zmarketbuyzone && !WeaponsIsClientInBuyZone(client)) { // Update cookie with new weapon. ZMarketSetRebuyCookie(client, slot, weapon); @@ -1089,7 +1076,7 @@ ZMarketRebuy(client, bool:autorebuy = false) } new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]); - if (!autorebuy && zmarketbuyzone && !ZMarketIsClientInBuyZone(client)) + if (!autorebuy && zmarketbuyzone && !WeaponsIsClientInBuyZone(client)) { TranslationPrintToChat(client, "Weapons zmarket buyzone"); return; @@ -1166,14 +1153,3 @@ public Action:ZMarketCommand(client, argc) // This stops the "Unknown command" message in client's console. return Plugin_Handled; } - -/** - * Checks if a client is in a buyzone. - * - * @param client The client index. - */ -stock bool:ZMarketIsClientInBuyZone(client) -{ - // Return if client is in buyzone. - return bool:GetEntData(client, g_iToolsInBuyZone); -}