Imported fix from dev: 646:25e5741ab71e - Moved the IsClientInBuyzone stock to the weapons module from ZMarket, and stop the "Zombies can't use weapons" phrase when using autobuy outside of a buyzone.

This commit is contained in:
Richard Helgeby 2010-02-14 17:03:19 +01:00
parent 05895df252
commit b39a684fd8
4 changed files with 34 additions and 29 deletions

View File

@ -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)

View File

@ -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;
}

View File

@ -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);
}

View File

@ -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);
}