Weapons module completed, added logging, thorough validations, and finished default configs.
This commit is contained in:
parent
44b0e776f2
commit
9031facaec
|
@ -10,6 +10,10 @@
|
||||||
// without these brackets the weapon will be skipped.
|
// without these brackets the weapon will be skipped.
|
||||||
// Invalid weapons are logged and skipped.
|
// Invalid weapons are logged and skipped.
|
||||||
// }
|
// }
|
||||||
|
//
|
||||||
|
// Notes:
|
||||||
|
//
|
||||||
|
// Invalid weapons (not in weapons.txt) will be logged in the error logs and ignored in-game
|
||||||
|
|
||||||
"weapongroups"
|
"weapongroups"
|
||||||
{
|
{
|
||||||
|
|
|
@ -8,6 +8,15 @@
|
||||||
// "menu" "yes" (default) // Allows admins to toggle restriction with the menu
|
// "menu" "yes" (default) // Allows admins to toggle restriction with the menu
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
|
// Notes:
|
||||||
|
//
|
||||||
|
// This is a list of valid weapons for your server, unlisted weapons will
|
||||||
|
// be seen as invalid by the weapon restrict module.
|
||||||
|
//
|
||||||
|
// A config setting set to something other than "yes" or "no" will be assumed as "no."
|
||||||
|
//
|
||||||
|
// A missing config setting will be assumed to be its default value (documented above).
|
||||||
|
//
|
||||||
// Duplicate weapon entries will show up separately in restrict menu, but
|
// Duplicate weapon entries will show up separately in restrict menu, but
|
||||||
// only the first one's options are used.
|
// only the first one's options are used.
|
||||||
|
|
||||||
|
@ -15,20 +24,20 @@
|
||||||
{
|
{
|
||||||
"Glock"
|
"Glock"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
//"restrict" "no"
|
||||||
"menu" "yes"
|
"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
"USP"
|
"USP"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "no"
|
||||||
"menu" "yes"
|
//"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
"P228"
|
"P228"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
//"restrict" "no"
|
||||||
"menu" "yes"
|
//"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Deagle"
|
"Deagle"
|
||||||
|
@ -135,19 +144,19 @@
|
||||||
|
|
||||||
"SG550"
|
"SG550"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "yes"
|
||||||
"menu" "yes"
|
"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
"G3SG1"
|
"G3SG1"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "yes"
|
||||||
"menu" "yes"
|
"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
"AWP"
|
"AWP"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "yes"
|
||||||
"menu" "yes"
|
"menu" "yes"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -165,14 +174,14 @@
|
||||||
|
|
||||||
"flashbang"
|
"flashbang"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "yes"
|
||||||
"menu" "yes"
|
"menu" "no"
|
||||||
}
|
}
|
||||||
|
|
||||||
"smokegrenade"
|
"smokegrenade"
|
||||||
{
|
{
|
||||||
"restrict" "no"
|
"restrict" "yes"
|
||||||
"menu" "yes"
|
"menu" "no"
|
||||||
}
|
}
|
||||||
|
|
||||||
"NVGs"
|
"NVGs"
|
||||||
|
|
|
@ -164,6 +164,17 @@
|
||||||
"ru" "Отображение здоровья включено."
|
"ru" "Отображение здоровья включено."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ===========================
|
||||||
|
// Generic
|
||||||
|
// ===========================
|
||||||
|
|
||||||
|
// Menu
|
||||||
|
|
||||||
|
"Menu empty"
|
||||||
|
{
|
||||||
|
"en" "(Empty)"
|
||||||
|
}
|
||||||
|
|
||||||
// ===========================
|
// ===========================
|
||||||
// Weapons
|
// Weapons
|
||||||
// ===========================
|
// ===========================
|
||||||
|
|
|
@ -135,6 +135,7 @@ public Action:Command_Respawn(client, argc)
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* Command callback for client command "zr_restrict"
|
||||||
* @param client The client index.
|
* @param client The client index.
|
||||||
* @param argc Argument count.
|
* @param argc Argument count.
|
||||||
*/
|
*/
|
||||||
|
@ -159,24 +160,14 @@ public Action:Command_Restrict(client, argc)
|
||||||
new WpnRestrictQuery:output = RestrictRestrict(arg1, display);
|
new WpnRestrictQuery:output = RestrictRestrict(arg1, display);
|
||||||
RestrictPrintRestrictOutput(client, output, display, true);
|
RestrictPrintRestrictOutput(client, output, display, true);
|
||||||
|
|
||||||
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS))
|
|
||||||
{
|
|
||||||
decl String:client_name[64];
|
|
||||||
|
|
||||||
if (client > 0)
|
|
||||||
{
|
|
||||||
GetClientName(client, client_name, sizeof(client_name));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client_name = "Console\0";
|
|
||||||
}
|
|
||||||
ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" restricted weapon (group): \"%s\".", true, client_name, arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Command callback for client command "zr_unrestrict"
|
||||||
|
* @param client The client index.
|
||||||
|
* @param argc Argument count.
|
||||||
|
*/
|
||||||
public Action:Command_Unrestrict(client, argc)
|
public Action:Command_Unrestrict(client, argc)
|
||||||
{
|
{
|
||||||
// If plugin is disabled then stop
|
// If plugin is disabled then stop
|
||||||
|
@ -198,21 +189,6 @@ public Action:Command_Unrestrict(client, argc)
|
||||||
new WpnRestrictQuery:output = RestrictUnrestrict(arg1, display);
|
new WpnRestrictQuery:output = RestrictUnrestrict(arg1, display);
|
||||||
RestrictPrintUnrestrictOutput(client, output, display, true);
|
RestrictPrintUnrestrictOutput(client, output, display, true);
|
||||||
|
|
||||||
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_COMMANDS))
|
|
||||||
{
|
|
||||||
decl String:client_name[64];
|
|
||||||
|
|
||||||
if (client > 0)
|
|
||||||
{
|
|
||||||
GetClientName(client, client_name, sizeof(client_name));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
client_name = "Console\0";
|
|
||||||
}
|
|
||||||
ZR_LogMessageFormatted(client, "admin commands", "weapon restict", "\"%s\" unrestricted weapon (group): \"%s\".", true, client_name, arg1);
|
|
||||||
}
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,6 +161,15 @@ WeaponsMenuWeapons(client, WeaponsMenu:type)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there are no weapons, add an "(Empty)" line
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
decl String:empty[64];
|
||||||
|
Format(empty, sizeof(empty), "%t", "Menu empty");
|
||||||
|
|
||||||
|
AddMenuItem(menu_weapons_weapons, "empty", empty, ITEMDRAW_DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
// Kill the array handle
|
// Kill the array handle
|
||||||
CloseHandle(arrayWeapons);
|
CloseHandle(arrayWeapons);
|
||||||
}
|
}
|
||||||
|
@ -170,7 +179,7 @@ WeaponsMenuWeapons(client, WeaponsMenu:type)
|
||||||
SetMenuTitle(menu_weapons_weapons, "%t\n ", "Weapons menu weapons group title");
|
SetMenuTitle(menu_weapons_weapons, "%t\n ", "Weapons menu weapons group title");
|
||||||
|
|
||||||
decl String:weapongroup[WEAPONS_MAX_LENGTH];
|
decl String:weapongroup[WEAPONS_MAX_LENGTH];
|
||||||
decl String:display[WEAPONS_MAX_LENGTH + 1];
|
decl String:display[WEAPONS_MAX_LENGTH + 2];
|
||||||
new Handle:arrayWeaponGroups = INVALID_HANDLE;
|
new Handle:arrayWeaponGroups = INVALID_HANDLE;
|
||||||
new size = RestrictCreateGroupArray(arrayWeaponGroups);
|
new size = RestrictCreateGroupArray(arrayWeaponGroups);
|
||||||
|
|
||||||
|
@ -193,6 +202,15 @@ WeaponsMenuWeapons(client, WeaponsMenu:type)
|
||||||
AddMenuItem(menu_weapons_weapons, weapongroup, display);
|
AddMenuItem(menu_weapons_weapons, weapongroup, display);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If there are no weapons, add an "(Empty)" line
|
||||||
|
if (size == 0)
|
||||||
|
{
|
||||||
|
decl String:empty[64];
|
||||||
|
Format(empty, sizeof(empty), "%t", "Menu empty");
|
||||||
|
|
||||||
|
AddMenuItem(menu_weapons_weapons, "empty", empty, ITEMDRAW_DISABLED);
|
||||||
|
}
|
||||||
|
|
||||||
// Kill the array handle
|
// Kill the array handle
|
||||||
CloseHandle(arrayWeaponGroups);
|
CloseHandle(arrayWeaponGroups);
|
||||||
}
|
}
|
||||||
|
@ -404,7 +422,7 @@ WeaponsMenuMarket(client)
|
||||||
decl String:togglebuyzone[64];
|
decl String:togglebuyzone[64];
|
||||||
|
|
||||||
decl String:curSetting[8];
|
decl String:curSetting[8];
|
||||||
BoolToConfigOption(GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]), curSetting, sizeof(curSetting));
|
BoolToConfigSetting(GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]), curSetting, sizeof(curSetting));
|
||||||
|
|
||||||
Format(togglebuyzone, sizeof(togglebuyzone), "%t", "Weapons menu market toggle buyzone", curSetting);
|
Format(togglebuyzone, sizeof(togglebuyzone), "%t", "Weapons menu market toggle buyzone", curSetting);
|
||||||
|
|
||||||
|
|
|
@ -46,9 +46,9 @@ RestrictInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads weapon data from file.
|
* Clears weapon restrict data
|
||||||
*/
|
*/
|
||||||
RestrictOnMapStart()
|
RestrictClearData()
|
||||||
{
|
{
|
||||||
// Clear restricted weapons
|
// Clear restricted weapons
|
||||||
RestrictWeaponUnrestrictAll();
|
RestrictWeaponUnrestrictAll();
|
||||||
|
@ -60,6 +60,15 @@ RestrictOnMapStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
kvWeaponGroups = CreateKeyValues("weapongroups");
|
kvWeaponGroups = CreateKeyValues("weapongroups");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads weapon data from file.
|
||||||
|
*/
|
||||||
|
RestrictOnMapStart()
|
||||||
|
{
|
||||||
|
// Restrict default restrictions (set in weapons.txt)
|
||||||
|
RestrictDefaultRestrictions();
|
||||||
|
|
||||||
decl String:path[PLATFORM_MAX_PATH];
|
decl String:path[PLATFORM_MAX_PATH];
|
||||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapongroups.txt");
|
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapongroups.txt");
|
||||||
|
@ -67,10 +76,14 @@ RestrictOnMapStart()
|
||||||
// If file isn't found, stop plugin
|
// If file isn't found, stop plugin
|
||||||
if (!FileToKeyValues(kvWeaponGroups, path))
|
if (!FileToKeyValues(kvWeaponGroups, path))
|
||||||
{
|
{
|
||||||
SetFailState("\"%s\" missing from server", path);
|
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapongroups.txt.", LOG_FORMAT_TYPE_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
RestrictDefaultRestrictions();
|
|
||||||
RestrictValidateWeaponGroups();
|
RestrictValidateWeaponGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,17 +97,25 @@ RestrictDefaultRestrictions()
|
||||||
if (KvGotoFirstSubKey(kvWeapons))
|
if (KvGotoFirstSubKey(kvWeapons))
|
||||||
{
|
{
|
||||||
decl String:weapon[WEAPONS_MAX_LENGTH];
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
||||||
decl String:display[WEAPONS_MAX_LENGTH + 1];
|
decl String:display[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
KvGetSectionName(kvWeapons, weapon, sizeof(weapon));
|
KvGetSectionName(kvWeapons, weapon, sizeof(weapon));
|
||||||
|
|
||||||
// If weapon is defaulted to restricted, then restrict weapon
|
// If weapon is defaulted to restricted, then restrict weapon
|
||||||
if (WeaponsIsRestrict(weapon))
|
decl String:restrict[8];
|
||||||
|
KvGetString(kvWeapons, "restrict", restrict, sizeof(restrict), "no");
|
||||||
|
|
||||||
|
if (ConfigSettingToBool(restrict))
|
||||||
{
|
{
|
||||||
new WpnRestrictQuery:output = RestrictRestrict(weapon, display);
|
new WpnRestrictQuery:output = RestrictRestrict(weapon, display);
|
||||||
RestrictPrintRestrictOutput(0, output, display, true);
|
RestrictPrintRestrictOutput(0, output, display, true);
|
||||||
|
|
||||||
|
// Function calls above screwed with the keyvalue stack, so we have to set it back
|
||||||
|
// to where it was before those calls
|
||||||
|
KvRewind(kvWeapons);
|
||||||
|
KvJumpToKey(kvWeapons, weapon);
|
||||||
}
|
}
|
||||||
} while (KvGotoNextKey(kvWeapons));
|
} while (KvGotoNextKey(kvWeapons));
|
||||||
}
|
}
|
||||||
|
@ -105,29 +126,41 @@ RestrictDefaultRestrictions()
|
||||||
*/
|
*/
|
||||||
RestrictValidateWeaponGroups()
|
RestrictValidateWeaponGroups()
|
||||||
{
|
{
|
||||||
|
// If log flag check fails, don't log
|
||||||
|
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
KvRewind(kvWeaponGroups);
|
KvRewind(kvWeaponGroups);
|
||||||
|
|
||||||
if (KvGotoFirstSubKey(kvWeaponGroups))
|
if (KvGotoFirstSubKey(kvWeaponGroups))
|
||||||
{
|
{
|
||||||
|
decl String:weapongroup[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:groupweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
KvGetSectionName(kvWeaponGroups, weapongroup, sizeof(weapongroup));
|
||||||
|
|
||||||
if (KvGotoFirstSubKey(kvWeaponGroups))
|
if (KvGotoFirstSubKey(kvWeaponGroups))
|
||||||
{
|
{
|
||||||
decl String:groupweapon[WEAPONS_MAX_LENGTH];
|
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
|
|
||||||
KvGetSectionName(kvWeaponGroups, groupweapon, sizeof(groupweapon));
|
KvGetSectionName(kvWeaponGroups, groupweapon, sizeof(groupweapon));
|
||||||
|
|
||||||
if (!WeaponsIsValidWeapon(groupweapon))
|
if (!WeaponsIsValidWeapon(groupweapon))
|
||||||
{
|
{
|
||||||
// VALIDATE
|
ZR_LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "Invalid weapon \"%s\" in group \"%s\" configured in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, groupweapon, weapongroup);
|
||||||
}
|
}
|
||||||
} while (KvGotoNextKey(kvWeaponGroups));
|
} while (KvGotoNextKey(kvWeaponGroups));
|
||||||
|
|
||||||
KvGoBack(kvWeaponGroups);
|
KvGoBack(kvWeaponGroups);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(-1, "Weapon Restrict", "Config Validation", "No weapons listed in weapon group \"%s\" in weapongroups.txt.", LOG_FORMAT_TYPE_ERROR, weapongroup);
|
||||||
|
}
|
||||||
} while (KvGotoNextKey(kvWeaponGroups));
|
} while (KvGotoNextKey(kvWeaponGroups));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -208,6 +241,8 @@ public Action:RestrictBuyHook(client, argc)
|
||||||
* Restricts a weapon.
|
* Restricts a weapon.
|
||||||
*
|
*
|
||||||
* @param weapon The weapon/group name.
|
* @param weapon The weapon/group name.
|
||||||
|
* @param display String set to the name set in weapons.txt
|
||||||
|
* Set to the value of 'weapon' if invalid
|
||||||
* @return Successful_Weapon: The call successfully restricted a weapon.
|
* @return Successful_Weapon: The call successfully restricted a weapon.
|
||||||
* Successful_Group: The call successfully restricted a weapon group.
|
* Successful_Group: The call successfully restricted a weapon group.
|
||||||
* Failed_Weapon: The call failed to restrict a weapon.
|
* Failed_Weapon: The call failed to restrict a weapon.
|
||||||
|
@ -252,13 +287,15 @@ WpnRestrictQuery:RestrictRestrict(const String:weapon[], String:display[] = "")
|
||||||
return Successful_Group;
|
return Successful_Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
WeaponGetDisplayName(weapon, display);
|
|
||||||
|
|
||||||
if (!WeaponsIsValidWeapon(weapon))
|
if (!WeaponsIsValidWeapon(weapon))
|
||||||
{
|
{
|
||||||
|
strcopy(display, WEAPONS_MAX_LENGTH, weapon);
|
||||||
|
|
||||||
return Invalid;
|
return Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WeaponGetDisplayName(weapon, display);
|
||||||
|
|
||||||
if (RestrictIsWeaponRestricted(weapon))
|
if (RestrictIsWeaponRestricted(weapon))
|
||||||
{
|
{
|
||||||
return Failed_Weapon;
|
return Failed_Weapon;
|
||||||
|
@ -273,6 +310,8 @@ WpnRestrictQuery:RestrictRestrict(const String:weapon[], String:display[] = "")
|
||||||
* Unrestricts a weapon.
|
* Unrestricts a weapon.
|
||||||
*
|
*
|
||||||
* @param weapon The weapon/group name.
|
* @param weapon The weapon/group name.
|
||||||
|
* @param display String set to the name set in weapons.txt
|
||||||
|
* Set to the value of 'weapon' if invalid
|
||||||
* @return Successful_Weapon: The call successfully restricted a weapon.
|
* @return Successful_Weapon: The call successfully restricted a weapon.
|
||||||
* Successful_Group: The call successfully restricted a weapon group.
|
* Successful_Group: The call successfully restricted a weapon group.
|
||||||
* Failed_Weapon: The call failed to restrict a weapon.
|
* Failed_Weapon: The call failed to restrict a weapon.
|
||||||
|
@ -321,13 +360,15 @@ WpnRestrictQuery:RestrictUnrestrict(const String:weapon[], String:display[] = ""
|
||||||
return Successful_Group;
|
return Successful_Group;
|
||||||
}
|
}
|
||||||
|
|
||||||
WeaponGetDisplayName(weapon, display);
|
|
||||||
|
|
||||||
if (!WeaponsIsValidWeapon(weapon))
|
if (!WeaponsIsValidWeapon(weapon))
|
||||||
{
|
{
|
||||||
|
strcopy(display, WEAPONS_MAX_LENGTH, weapon);
|
||||||
|
|
||||||
return Invalid;
|
return Invalid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WeaponGetDisplayName(weapon, display);
|
||||||
|
|
||||||
if (!RestrictIsWeaponRestricted(weapon))
|
if (!RestrictIsWeaponRestricted(weapon))
|
||||||
{
|
{
|
||||||
return Failed_Weapon;
|
return Failed_Weapon;
|
||||||
|
@ -356,6 +397,11 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
||||||
case Successful_Weapon:
|
case Successful_Weapon:
|
||||||
{
|
{
|
||||||
ZR_PrintToChat(0, "Restrict weapon", weapon);
|
ZR_PrintToChat(0, "Restrict weapon", weapon);
|
||||||
|
|
||||||
|
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case Successful_Group:
|
case Successful_Group:
|
||||||
{
|
{
|
||||||
|
@ -363,6 +409,11 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
||||||
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
||||||
|
|
||||||
ZR_PrintToChat(0, "Restrict custom weapon group", weapon, weaponlist);
|
ZR_PrintToChat(0, "Restrict custom weapon group", weapon, weaponlist);
|
||||||
|
|
||||||
|
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(client, "Weapon Restrict", "Restrict", "\"%L\" restricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case Failed_Weapon:
|
case Failed_Weapon:
|
||||||
{
|
{
|
||||||
|
@ -417,6 +468,11 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
||||||
case Successful_Weapon:
|
case Successful_Weapon:
|
||||||
{
|
{
|
||||||
ZR_PrintToChat(0, "Unrestrict weapon", weapon);
|
ZR_PrintToChat(0, "Unrestrict weapon", weapon);
|
||||||
|
|
||||||
|
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case Successful_Group:
|
case Successful_Group:
|
||||||
{
|
{
|
||||||
|
@ -424,6 +480,11 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
||||||
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
||||||
|
|
||||||
ZR_PrintToChat(0, "Unrestrict custom weapon group", weapon, weaponlist);
|
ZR_PrintToChat(0, "Unrestrict custom weapon group", weapon, weaponlist);
|
||||||
|
|
||||||
|
if (LogFlagCheck(LOG_GAME_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(client, "Weapon Restrict", "Unrestrict", "\"%L\" unrestricted weapon group: \"%s\".", LOG_FORMAT_TYPE_FULL, client, weapon);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
case Failed_Weapon:
|
case Failed_Weapon:
|
||||||
{
|
{
|
||||||
|
@ -471,10 +532,11 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
||||||
*/
|
*/
|
||||||
bool:RestrictIsWeaponRestricted(const String:weapon[])
|
bool:RestrictIsWeaponRestricted(const String:weapon[])
|
||||||
{
|
{
|
||||||
|
decl String:restrictedweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
new size = GetArraySize(gRestrictedWeapons);
|
new size = GetArraySize(gRestrictedWeapons);
|
||||||
for (new x = 0; x < size; x++)
|
for (new x = 0; x < size; x++)
|
||||||
{
|
{
|
||||||
decl String:restrictedweapon[WEAPONS_MAX_LENGTH];
|
|
||||||
GetArrayString(gRestrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
GetArrayString(gRestrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
||||||
|
|
||||||
if (StrEqual(weapon, restrictedweapon, false))
|
if (StrEqual(weapon, restrictedweapon, false))
|
||||||
|
@ -567,10 +629,11 @@ bool:RestrictIsPartialRestricted(const String:weapongroup[])
|
||||||
*/
|
*/
|
||||||
RestrictGetIndex(const String:weapon[])
|
RestrictGetIndex(const String:weapon[])
|
||||||
{
|
{
|
||||||
|
decl String:restrictedweapon[WEAPONS_MAX_LENGTH];
|
||||||
|
|
||||||
new size = GetArraySize(gRestrictedWeapons);
|
new size = GetArraySize(gRestrictedWeapons);
|
||||||
for (new x = 0; x < size; x++)
|
for (new x = 0; x < size; x++)
|
||||||
{
|
{
|
||||||
decl String:restrictedweapon[WEAPONS_MAX_LENGTH];
|
|
||||||
GetArrayString(gRestrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
GetArrayString(gRestrictedWeapons, x, restrictedweapon, sizeof(restrictedweapon));
|
||||||
|
|
||||||
if (StrEqual(weapon, restrictedweapon, false))
|
if (StrEqual(weapon, restrictedweapon, false))
|
||||||
|
|
|
@ -24,6 +24,9 @@ new Handle:kvWeapons = INVALID_HANDLE;
|
||||||
#include "zr/weapons/markethandler"
|
#include "zr/weapons/markethandler"
|
||||||
#include "zr/weapons/menu_weapons"
|
#include "zr/weapons/menu_weapons"
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Weapons module init function
|
||||||
|
*/
|
||||||
WeaponsInit()
|
WeaponsInit()
|
||||||
{
|
{
|
||||||
// Forward event to sub-module
|
// Forward event to sub-module
|
||||||
|
@ -31,9 +34,9 @@ WeaponsInit()
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Loads weapon data from file.
|
* Clears weapon data
|
||||||
*/
|
*/
|
||||||
WeaponsOnMapStart()
|
WeaponsClearData()
|
||||||
{
|
{
|
||||||
// Load weapon data
|
// Load weapon data
|
||||||
if (kvWeapons != INVALID_HANDLE)
|
if (kvWeapons != INVALID_HANDLE)
|
||||||
|
@ -42,6 +45,18 @@ WeaponsOnMapStart()
|
||||||
}
|
}
|
||||||
|
|
||||||
kvWeapons = CreateKeyValues("weapons");
|
kvWeapons = CreateKeyValues("weapons");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads weapon data from file.
|
||||||
|
*/
|
||||||
|
WeaponsOnMapStart()
|
||||||
|
{
|
||||||
|
// Clear weapon data
|
||||||
|
WeaponsClearData();
|
||||||
|
|
||||||
|
// Clear weapon restrict data
|
||||||
|
RestrictClearData();
|
||||||
|
|
||||||
decl String:path[PLATFORM_MAX_PATH];
|
decl String:path[PLATFORM_MAX_PATH];
|
||||||
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapons.txt");
|
BuildPath(Path_SM, path, sizeof(path), "configs/zr/weapons/weapons.txt");
|
||||||
|
@ -49,7 +64,12 @@ WeaponsOnMapStart()
|
||||||
// If file isn't found, stop plugin
|
// If file isn't found, stop plugin
|
||||||
if (!FileToKeyValues(kvWeapons, path))
|
if (!FileToKeyValues(kvWeapons, path))
|
||||||
{
|
{
|
||||||
SetFailState("\"%s\" missing from server", path);
|
if (LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
|
{
|
||||||
|
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "Missing file weapons.txt, disabling weapons-based modules.", LOG_FORMAT_TYPE_FULL);
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Validate weapons config
|
// Validate weapons config
|
||||||
|
@ -61,22 +81,16 @@ WeaponsOnMapStart()
|
||||||
|
|
||||||
WeaponsValidateWeaponsConfig()
|
WeaponsValidateWeaponsConfig()
|
||||||
{
|
{
|
||||||
KvRewind(kvWeapons);
|
// If log flag check fails, don't log
|
||||||
if (KvGotoFirstSubKey(kvWeapons))
|
if (!LogFlagCheck(LOG_CORE_EVENTS, LOG_MODULE_WEAPONS))
|
||||||
{
|
{
|
||||||
decl String:weapon[WEAPONS_MAX_LENGTH];
|
return;
|
||||||
decl String:restrict[8];
|
}
|
||||||
decl String:menu[8];
|
|
||||||
|
|
||||||
do
|
KvRewind(kvWeapons);
|
||||||
{
|
if (!KvGotoFirstSubKey(kvWeapons))
|
||||||
KvGetSectionName(kvWeapons, weapon, sizeof(weapon));
|
{
|
||||||
KvGetString(kvWeapons, "restrict", restrict, sizeof(restrict), "no");
|
ZR_LogMessageFormatted(-1, "Weapons", "Config Validation", "No weapons listed in weapons.txt, disabling weapons-based modules.", LOG_FORMAT_TYPE_FULL);
|
||||||
KvGetString(kvWeapons, "menu", menu, sizeof(menu), "yes");
|
|
||||||
|
|
||||||
// VALIDATE
|
|
||||||
|
|
||||||
} while (KvGotoNextKey(kvWeapons));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -172,35 +186,6 @@ WeaponGetDisplayName(const String:weapon[], String:display[])
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Checks if a weapon is restricted by default.
|
|
||||||
* @param weapon The weapon name.
|
|
||||||
* @return Returns true if restricted, false it not.
|
|
||||||
*/
|
|
||||||
bool:WeaponsIsRestrict(const String:weapon[])
|
|
||||||
{
|
|
||||||
KvRewind(kvWeapons);
|
|
||||||
if (KvGotoFirstSubKey(kvWeapons))
|
|
||||||
{
|
|
||||||
decl String:validweapon[WEAPONS_MAX_LENGTH];
|
|
||||||
decl String:restrict[8];
|
|
||||||
|
|
||||||
do
|
|
||||||
{
|
|
||||||
KvGetSectionName(kvWeapons, validweapon, sizeof(validweapon));
|
|
||||||
|
|
||||||
if (StrEqual(validweapon, weapon, false))
|
|
||||||
{
|
|
||||||
KvGetString(kvWeapons, "restrict", restrict, sizeof(restrict), "no");
|
|
||||||
|
|
||||||
return ConfigOptionToBool(restrict);
|
|
||||||
}
|
|
||||||
} while (KvGotoNextKey(kvWeapons));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks if a weapon restriction can be toggled by the admin menu.
|
* Checks if a weapon restriction can be toggled by the admin menu.
|
||||||
* @param weapon The weapon name.
|
* @param weapon The weapon name.
|
||||||
|
@ -222,7 +207,7 @@ bool:WeaponsIsWeaponMenu(const String:weapon[])
|
||||||
{
|
{
|
||||||
KvGetString(kvWeapons, "menu", menu, sizeof(menu), "yes");
|
KvGetString(kvWeapons, "menu", menu, sizeof(menu), "yes");
|
||||||
|
|
||||||
return ConfigOptionToBool(menu);
|
return ConfigSettingToBool(menu);
|
||||||
}
|
}
|
||||||
} while (KvGotoNextKey(kvWeapons));
|
} while (KvGotoNextKey(kvWeapons));
|
||||||
}
|
}
|
||||||
|
|
|
@ -113,7 +113,7 @@ new Handle:tHandles[MAXPLAYERS + 1][MAXTIMERS];
|
||||||
|
|
||||||
new QueryCookie:mat_dxlevel;
|
new QueryCookie:mat_dxlevel;
|
||||||
|
|
||||||
bool:ConfigOptionToBool(const String:option[])
|
bool:ConfigSettingToBool(const String:option[])
|
||||||
{
|
{
|
||||||
if (StrEqual(option, "yes", false))
|
if (StrEqual(option, "yes", false))
|
||||||
{
|
{
|
||||||
|
@ -123,7 +123,7 @@ bool:ConfigOptionToBool(const String:option[])
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
BoolToConfigOption(bool:bOption, String:option[], maxlen)
|
BoolToConfigSetting(bool:bOption, String:option[], maxlen)
|
||||||
{
|
{
|
||||||
if (bOption)
|
if (bOption)
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user