Made config module, recoded models.inc and added validations, added a cvar to flag any sayhook as quiet to hide from chat, hooked mp_limitteams, fixed menu handle function, moved file paths into cvars and updated all modules but classes to use it
This commit is contained in:
@ -19,7 +19,7 @@ new bool:g_bMarket;
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
bool:ZMarketSend(client)
|
||||
bool:ZMarketMenu(client)
|
||||
{
|
||||
// If market is disabled, then stop.
|
||||
if (!g_bMarket)
|
||||
@ -151,5 +151,5 @@ public Market_PostOnWeaponSelected(client, &bool:allowed)
|
||||
}
|
||||
|
||||
// Resend market menu.
|
||||
ZMarketSend(client);
|
||||
ZMarketMenu(client);
|
||||
}
|
@ -48,16 +48,7 @@ WeaponsMenuMain(client)
|
||||
|
||||
AddMenuItem(menu_weapons_main, "toggleweaponrestriction", toggleweaponrestriction);
|
||||
AddMenuItem(menu_weapons_main, "togglewgrouprestriction", togglewgrouprestriction);
|
||||
|
||||
// Disable market option if market isn't installed.
|
||||
if (g_bMarket)
|
||||
{
|
||||
AddMenuItem(menu_weapons_main, "zmarket", zmarket);
|
||||
}
|
||||
else
|
||||
{
|
||||
AddMenuItem(menu_weapons_main, "zmarket", zmarket, ITEMDRAW_DISABLED);
|
||||
}
|
||||
AddMenuItem(menu_weapons_main, "zmarket", zmarket, MenuGetItemDraw(g_bMarket));
|
||||
|
||||
// Create a "Back" button to the weapons main menu.
|
||||
SetMenuExitBackButton(menu_weapons_main, true);
|
||||
|
@ -82,20 +82,26 @@ RestrictOnMapStart()
|
||||
// Restrict default restrictions. (set in weapons.txt)
|
||||
RestrictDefaultRestrictions();
|
||||
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapongroups.txt");
|
||||
// Get weapon groups config path.
|
||||
decl String:pathweapongroups[PLATFORM_MAX_PATH];
|
||||
new bool:exists = ConfigGetFilePath(CVAR_CONFIG_PATH_WEAPONGROUPS, pathweapongroups);
|
||||
|
||||
// If file isn't found, stop plugin.
|
||||
if (!FileToKeyValues(kvWeaponGroups, path))
|
||||
// If file doesn't exist, then log and stop.
|
||||
if (!exists)
|
||||
{
|
||||
// Log failure.
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||
{
|
||||
LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapongroups.txt.", LOG_FORMAT_TYPE_ERROR);
|
||||
LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing weapon groups config file: %s", LOG_FORMAT_TYPE_ERROR, pathweapongroups);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Put file data into memory.
|
||||
FileToKeyValues(kvWeaponGroups, pathweapongroups);
|
||||
|
||||
// Validate weapon groups config.
|
||||
RestrictValidateWeaponGroups();
|
||||
}
|
||||
|
||||
@ -197,6 +203,7 @@ RestrictWeaponUnrestrictAll()
|
||||
*/
|
||||
RestrictClientInit(client)
|
||||
{
|
||||
// Hook "canuse" on client.
|
||||
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
|
||||
}
|
||||
|
||||
@ -207,9 +214,22 @@ RestrictClientInit(client)
|
||||
*/
|
||||
RestrictOnClientDisconnect(client)
|
||||
{
|
||||
// Unhook "canuse" on client.
|
||||
Hacks_Unhook(gCanUseHookID[client]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Client is spawning into the game.
|
||||
*
|
||||
* @param client The client index.
|
||||
*/
|
||||
RestrictOnClientSpawn(client)
|
||||
{
|
||||
// Re-hook "canuse" on client.
|
||||
Hacks_Unhook(gCanUseHookID[client]);
|
||||
gCanUseHookID[client] = Hacks_Hook(client, HACKS_HTYPE_WEAPON_CANUSE, RestrictCanUse, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Command callback function for the "buy" command
|
||||
* Used to block use of this command under certain conditions.
|
||||
|
@ -82,20 +82,25 @@ WeaponsLoad()
|
||||
return;
|
||||
}
|
||||
|
||||
decl String:path[PLATFORM_MAX_PATH];
|
||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapons.txt");
|
||||
// Get weapons config path.
|
||||
decl String:pathweapons[PLATFORM_MAX_PATH];
|
||||
new bool:exists = ConfigGetFilePath(CVAR_CONFIG_PATH_WEAPONS, pathweapons);
|
||||
|
||||
// If file isn't found, stop plugin.
|
||||
if (!FileToKeyValues(kvWeapons, path))
|
||||
// If file doesn't exist, then log and stop.
|
||||
if (!exists)
|
||||
{
|
||||
// Log failure.
|
||||
if (LogCheckFlag(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||
{
|
||||
LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapons.txt.", LOG_FORMAT_TYPE_ERROR);
|
||||
LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing weapons config file: %s", LOG_FORMAT_TYPE_ERROR, pathweapons);
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
// Put file data into memory.
|
||||
FileToKeyValues(kvWeapons, pathweapons);
|
||||
|
||||
// Validate weapons config.
|
||||
WeaponsValidateConfig();
|
||||
|
||||
|
Reference in New Issue
Block a user