Added default restrictions, added market options in the menu
This commit is contained in:
parent
0d5b805387
commit
44b0e776f2
@ -285,6 +285,17 @@
|
|||||||
"en" "Modify Restrictions:\n Current Weapon Group: {1}\n * = restricted"
|
"en" "Modify Restrictions:\n Current Weapon Group: {1}\n * = restricted"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Weapons menu market title"
|
||||||
|
{
|
||||||
|
"en" "Toggle Market Settings:"
|
||||||
|
}
|
||||||
|
|
||||||
|
"Weapons menu market toggle buyzone"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Buyzone Only (Current: {1})"
|
||||||
|
}
|
||||||
|
|
||||||
"Weapons menu weapon group restrict all"
|
"Weapons menu weapon group restrict all"
|
||||||
{
|
{
|
||||||
"en" "Restrict All Group Weapons"
|
"en" "Restrict All Group Weapons"
|
||||||
|
@ -45,16 +45,10 @@ ammo_57mm_max 500 // p90, fiveseven
|
|||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
//
|
//
|
||||||
// Weapon Restrictions
|
// Weapon Restrictions (Deprecated)
|
||||||
//
|
//
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
|
|
||||||
zr_restrict "flashbang"
|
|
||||||
zr_restrict "smokegrenade"
|
|
||||||
zr_restrict "m249"
|
|
||||||
zr_restrict "snipers"
|
|
||||||
zr_restrict "nvgs"
|
|
||||||
|
|
||||||
|
|
||||||
// ------------------------------------
|
// ------------------------------------
|
||||||
//
|
//
|
||||||
|
@ -40,7 +40,6 @@ WeaponsMenuMain(client)
|
|||||||
|
|
||||||
decl String:toggleweaponrestriction[64];
|
decl String:toggleweaponrestriction[64];
|
||||||
decl String:togglewgrouprestriction[64];
|
decl String:togglewgrouprestriction[64];
|
||||||
|
|
||||||
decl String:zmarket[64];
|
decl String:zmarket[64];
|
||||||
|
|
||||||
Format(toggleweaponrestriction, sizeof(toggleweaponrestriction), "%t", "Weapons menu main toggle weapon restrict");
|
Format(toggleweaponrestriction, sizeof(toggleweaponrestriction), "%t", "Weapons menu main toggle weapon restrict");
|
||||||
@ -91,7 +90,7 @@ public WeaponsMenuMainHandle(Handle:menu_weapons_main, MenuAction:action, client
|
|||||||
}
|
}
|
||||||
case 2:
|
case 2:
|
||||||
{
|
{
|
||||||
//WeaponsMenuMarket(client);
|
WeaponsMenuMarket(client);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -142,8 +141,6 @@ WeaponsMenuWeapons(client, WeaponsMenu:type)
|
|||||||
{
|
{
|
||||||
GetArrayString(arrayWeapons, x, weapon, sizeof(weapon));
|
GetArrayString(arrayWeapons, x, weapon, sizeof(weapon));
|
||||||
|
|
||||||
new bool:menu = WeaponsIsWeaponMenu(weapon);
|
|
||||||
|
|
||||||
strcopy(display, sizeof(display), weapon);
|
strcopy(display, sizeof(display), weapon);
|
||||||
|
|
||||||
if (RestrictIsWeaponRestricted(weapon))
|
if (RestrictIsWeaponRestricted(weapon))
|
||||||
@ -152,6 +149,8 @@ WeaponsMenuWeapons(client, WeaponsMenu:type)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If weapon restriction is blocked for the menu, disable option
|
// If weapon restriction is blocked for the menu, disable option
|
||||||
|
new bool:menu = WeaponsIsWeaponMenu(weapon);
|
||||||
|
|
||||||
if (menu)
|
if (menu)
|
||||||
{
|
{
|
||||||
AddMenuItem(menu_weapons_weapons, weapon, display);
|
AddMenuItem(menu_weapons_weapons, weapon, display);
|
||||||
@ -388,3 +387,78 @@ public WeaponsMenuWeaponGroupHandle(Handle:menu_weapons_groupweapon, MenuAction:
|
|||||||
CloseHandle(menu_weapons_groupweapon);
|
CloseHandle(menu_weapons_groupweapon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends market options menu to client.
|
||||||
|
* @param client The client index.
|
||||||
|
*/
|
||||||
|
WeaponsMenuMarket(client)
|
||||||
|
{
|
||||||
|
// Create menu handle
|
||||||
|
new Handle:menu_weapons_market = CreateMenu(WeaponsMenuMarketHandle);
|
||||||
|
|
||||||
|
SetGlobalTransTarget(client);
|
||||||
|
|
||||||
|
SetMenuTitle(menu_weapons_market, "%t\n ", "Weapons menu market title");
|
||||||
|
|
||||||
|
decl String:togglebuyzone[64];
|
||||||
|
|
||||||
|
decl String:curSetting[8];
|
||||||
|
BoolToConfigOption(GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]), curSetting, sizeof(curSetting));
|
||||||
|
|
||||||
|
Format(togglebuyzone, sizeof(togglebuyzone), "%t", "Weapons menu market toggle buyzone", curSetting);
|
||||||
|
|
||||||
|
AddMenuItem(menu_weapons_market, "togglebuyzone", togglebuyzone);
|
||||||
|
|
||||||
|
// Create a "Back" button to the weapons main menu
|
||||||
|
SetMenuExitBackButton(menu_weapons_market, true);
|
||||||
|
|
||||||
|
// Send menu
|
||||||
|
DisplayMenu(menu_weapons_market, client, MENU_TIME_FOREVER);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Called when client selects option in the weapons main menu, and handles it.
|
||||||
|
* @param menu_weapons_main Handle of the menu being used.
|
||||||
|
* @param action The action done on the menu (see menus.inc, enum MenuAction).
|
||||||
|
* @param client The client index.
|
||||||
|
* @param slot The slot index selected (starting from 0).
|
||||||
|
*/
|
||||||
|
public WeaponsMenuMarketHandle(Handle:menu_weapons_market, MenuAction:action, client, slot)
|
||||||
|
{
|
||||||
|
// Client selected an option
|
||||||
|
if (action == MenuAction_Select)
|
||||||
|
{
|
||||||
|
switch(slot)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
{
|
||||||
|
if (GetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE]))
|
||||||
|
{
|
||||||
|
SetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE], false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
SetConVarBool(gCvars[CVAR_ZMARKET_BUYZONE], true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Resend menu
|
||||||
|
WeaponsMenuMarket(client);
|
||||||
|
}
|
||||||
|
// Client closed the menu
|
||||||
|
if (action == MenuAction_Cancel)
|
||||||
|
{
|
||||||
|
// Client hit "Back" button
|
||||||
|
if (slot == MenuCancel_ExitBack)
|
||||||
|
{
|
||||||
|
WeaponsMenuMain(client);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// Client hit "Exit" button
|
||||||
|
else if (action == MenuAction_End)
|
||||||
|
{
|
||||||
|
CloseHandle(menu_weapons_market);
|
||||||
|
}
|
||||||
|
}
|
@ -70,9 +70,39 @@ RestrictOnMapStart()
|
|||||||
SetFailState("\"%s\" missing from server", path);
|
SetFailState("\"%s\" missing from server", path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
RestrictDefaultRestrictions();
|
||||||
RestrictValidateWeaponGroups();
|
RestrictValidateWeaponGroups();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Restrict default restrictions (set in weapons.txt)
|
||||||
|
*/
|
||||||
|
RestrictDefaultRestrictions()
|
||||||
|
{
|
||||||
|
KvRewind(kvWeapons);
|
||||||
|
|
||||||
|
if (KvGotoFirstSubKey(kvWeapons))
|
||||||
|
{
|
||||||
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
||||||
|
decl String:display[WEAPONS_MAX_LENGTH + 1];
|
||||||
|
|
||||||
|
do
|
||||||
|
{
|
||||||
|
KvGetSectionName(kvWeapons, weapon, sizeof(weapon));
|
||||||
|
|
||||||
|
// If weapon is defaulted to restricted, then restrict weapon
|
||||||
|
if (WeaponsIsRestrict(weapon))
|
||||||
|
{
|
||||||
|
new WpnRestrictQuery:output = RestrictRestrict(weapon, display);
|
||||||
|
RestrictPrintRestrictOutput(0, output, display, true);
|
||||||
|
}
|
||||||
|
} while (KvGotoNextKey(kvWeapons));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validate weapon group options
|
||||||
|
*/
|
||||||
RestrictValidateWeaponGroups()
|
RestrictValidateWeaponGroups()
|
||||||
{
|
{
|
||||||
KvRewind(kvWeaponGroups);
|
KvRewind(kvWeaponGroups);
|
||||||
@ -319,7 +349,7 @@ WpnRestrictQuery:RestrictUnrestrict(const String:weapon[], String:display[] = ""
|
|||||||
* @param weapon The weapon client is trying to restrict.
|
* @param weapon The weapon client is trying to restrict.
|
||||||
* @param cmd True if printing output in reply to a client command.
|
* @param cmd True if printing output in reply to a client command.
|
||||||
*/
|
*/
|
||||||
RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon[], bool:cmd)
|
RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon[], bool:reply)
|
||||||
{
|
{
|
||||||
switch(output)
|
switch(output)
|
||||||
{
|
{
|
||||||
@ -336,7 +366,7 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
|||||||
}
|
}
|
||||||
case Failed_Weapon:
|
case Failed_Weapon:
|
||||||
{
|
{
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Restrict weapon failed", weapon);
|
ZR_ReplyToCommand(client, "Restrict weapon failed", weapon);
|
||||||
}
|
}
|
||||||
@ -350,7 +380,7 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
|||||||
decl String:weaponlist[128];
|
decl String:weaponlist[128];
|
||||||
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
||||||
|
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Restrict custom weapon group failed", weapon, weaponlist);
|
ZR_ReplyToCommand(client, "Restrict custom weapon group failed", weapon, weaponlist);
|
||||||
}
|
}
|
||||||
@ -361,7 +391,7 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
|||||||
}
|
}
|
||||||
case Invalid:
|
case Invalid:
|
||||||
{
|
{
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Weapon invalid", weapon);
|
ZR_ReplyToCommand(client, "Weapon invalid", weapon);
|
||||||
}
|
}
|
||||||
@ -380,7 +410,7 @@ RestrictPrintRestrictOutput(client, WpnRestrictQuery:output, const String:weapon
|
|||||||
* @param weapon The weapon client is trying to unrestrict.
|
* @param weapon The weapon client is trying to unrestrict.
|
||||||
* @param cmd True if printing output in reply to a client command.
|
* @param cmd True if printing output in reply to a client command.
|
||||||
*/
|
*/
|
||||||
RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weapon[], bool:cmd)
|
RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weapon[], bool:reply)
|
||||||
{
|
{
|
||||||
switch(output)
|
switch(output)
|
||||||
{
|
{
|
||||||
@ -397,7 +427,7 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
|||||||
}
|
}
|
||||||
case Failed_Weapon:
|
case Failed_Weapon:
|
||||||
{
|
{
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Unrestrict weapon failed", weapon);
|
ZR_ReplyToCommand(client, "Unrestrict weapon failed", weapon);
|
||||||
}
|
}
|
||||||
@ -411,7 +441,7 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
|||||||
decl String:weaponlist[128];
|
decl String:weaponlist[128];
|
||||||
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
RestrictGetGroupWeapons(weapon, weaponlist, sizeof(weaponlist), ", ");
|
||||||
|
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Unrestrict custom weapon group failed", weapon, weaponlist);
|
ZR_ReplyToCommand(client, "Unrestrict custom weapon group failed", weapon, weaponlist);
|
||||||
}
|
}
|
||||||
@ -422,7 +452,7 @@ RestrictPrintUnrestrictOutput(client, WpnRestrictQuery:output, const String:weap
|
|||||||
}
|
}
|
||||||
case Invalid:
|
case Invalid:
|
||||||
{
|
{
|
||||||
if (cmd)
|
if (reply)
|
||||||
{
|
{
|
||||||
ZR_ReplyToCommand(client, "Weapon invalid", weapon);
|
ZR_ReplyToCommand(client, "Weapon invalid", weapon);
|
||||||
}
|
}
|
||||||
|
@ -191,7 +191,7 @@ bool:WeaponsIsRestrict(const String:weapon[])
|
|||||||
|
|
||||||
if (StrEqual(validweapon, weapon, false))
|
if (StrEqual(validweapon, weapon, false))
|
||||||
{
|
{
|
||||||
KvGetString(kvWeapons, validweapon, restrict, sizeof(restrict), "no");
|
KvGetString(kvWeapons, "restrict", restrict, sizeof(restrict), "no");
|
||||||
|
|
||||||
return ConfigOptionToBool(restrict);
|
return ConfigOptionToBool(restrict);
|
||||||
}
|
}
|
||||||
@ -220,7 +220,7 @@ bool:WeaponsIsWeaponMenu(const String:weapon[])
|
|||||||
|
|
||||||
if (StrEqual(validweapon, weapon, false))
|
if (StrEqual(validweapon, weapon, false))
|
||||||
{
|
{
|
||||||
KvGetString(kvWeapons, validweapon, menu, sizeof(menu), "yes");
|
KvGetString(kvWeapons, "menu", menu, sizeof(menu), "yes");
|
||||||
|
|
||||||
return ConfigOptionToBool(menu);
|
return ConfigOptionToBool(menu);
|
||||||
}
|
}
|
||||||
|
@ -123,6 +123,18 @@ bool:ConfigOptionToBool(const String:option[])
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoolToConfigOption(bool:bOption, String:option[], maxlen)
|
||||||
|
{
|
||||||
|
if (bOption)
|
||||||
|
{
|
||||||
|
strcopy(option, maxlen, "yes");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
strcopy(option, maxlen, "no");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
FindClientDXLevel(client)
|
FindClientDXLevel(client)
|
||||||
{
|
{
|
||||||
if (IsFakeClient(client))
|
if (IsFakeClient(client))
|
||||||
|
Loading…
Reference in New Issue
Block a user