2009-05-06 02:28:09 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2009-07-05 08:49:23 +02:00
|
|
|
* Zombie:Reloaded
|
2009-05-06 02:28:09 +02:00
|
|
|
*
|
2009-06-05 05:58:48 +02:00
|
|
|
* File: menu_weapons.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Handles weapons management menu.
|
|
|
|
*
|
2013-01-12 08:47:36 +01:00
|
|
|
* Copyright (C) 2009-2013 Greyscale, Richard Helgeby
|
2009-06-05 05:58:48 +02:00
|
|
|
*
|
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2009-05-06 02:28:09 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
2009-04-12 08:04:00 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
2009-05-29 08:43:15 +02:00
|
|
|
* Array to store the client's current weapon type within menu.
|
2009-04-12 08:04:00 +02:00
|
|
|
*/
|
2009-06-05 05:58:48 +02:00
|
|
|
new g_iWeaponsCurType[MAXPLAYERS + 1];
|
2009-04-13 23:55:02 +02:00
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
/**
|
|
|
|
* Sends main weapon menu to client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-12 08:04:00 +02:00
|
|
|
* @param client The client index.
|
2009-05-29 08:43:15 +02:00
|
|
|
*/
|
2009-06-08 06:05:50 +02:00
|
|
|
bool:WeaponsMenuMain(client)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-06-08 06:05:50 +02:00
|
|
|
// If weapons module is disabled, then stop.
|
|
|
|
new bool:weapons = GetConVarBool(g_hCvarsList[CVAR_WEAPONS]);
|
|
|
|
if (!weapons)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create menu handle.
|
2009-04-12 08:04:00 +02:00
|
|
|
new Handle:menu_weapons_main = CreateMenu(WeaponsMenuMainHandle);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
decl String:title[MENU_LINE_TITLE_LENGTH];
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:restrict[MENU_LINE_SMALL_LENGTH];
|
|
|
|
decl String:zmarket[MENU_LINE_SMALL_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict main title");
|
2009-06-05 05:58:48 +02:00
|
|
|
Format(restrict, sizeof(restrict), "%t", "Weapons menu restrict main restrict");
|
|
|
|
Format(zmarket, sizeof(zmarket), "%t", "Weapons menu restrict main market");
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Draw items, make unselectable if module is disabled.
|
2009-07-28 02:02:49 +02:00
|
|
|
SetMenuTitle(menu_weapons_main, title);
|
2009-05-29 08:43:15 +02:00
|
|
|
AddMenuItem(menu_weapons_main, "restrict", restrict, MenuGetItemDraw(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_RESTRICT])));
|
|
|
|
AddMenuItem(menu_weapons_main, "zmarket", zmarket, MenuGetItemDraw(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET])));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create a "Back" button to the weapons main menu.
|
2009-04-12 08:04:00 +02:00
|
|
|
SetMenuExitBackButton(menu_weapons_main, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Send menu.
|
2009-04-12 08:04:00 +02:00
|
|
|
DisplayMenu(menu_weapons_main, client, MENU_TIME_FOREVER);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-06-08 06:05:50 +02:00
|
|
|
return true;
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when client selects option in the weapons main menu, and handles it.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-12 08:04:00 +02:00
|
|
|
* @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).
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-04-12 08:04:00 +02:00
|
|
|
public WeaponsMenuMainHandle(Handle:menu_weapons_main, MenuAction:action, client, slot)
|
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client selected an option.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
switch(slot)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Weapons.
|
2009-04-12 08:04:00 +02:00
|
|
|
case 0:
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
WeaponsMenuTypes(client);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
2009-05-29 08:43:15 +02:00
|
|
|
// ZMarket.
|
2009-04-12 08:04:00 +02:00
|
|
|
case 1:
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
WeaponsMenuZMarket(client);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client closed the menu.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Back" button.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Re-open admin menu.
|
2009-06-26 02:03:34 +02:00
|
|
|
ZAdminMenu(client);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Exit" button.
|
2009-04-12 08:04:00 +02:00
|
|
|
else if (action == MenuAction_End)
|
|
|
|
{
|
|
|
|
CloseHandle(menu_weapons_main);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-05-29 08:43:15 +02:00
|
|
|
* Sends weapon type list to client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-12 08:04:00 +02:00
|
|
|
* @param client The client index.
|
2009-05-29 08:43:15 +02:00
|
|
|
*/
|
|
|
|
WeaponsMenuTypes(client)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create menu handle.
|
2009-05-29 08:43:15 +02:00
|
|
|
new Handle:menu_weapons_types = CreateMenu(WeaponsMenuTypesHandle);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
decl String:title[MENU_LINE_TITLE_LENGTH];
|
|
|
|
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict types title");
|
|
|
|
SetMenuTitle(menu_weapons_types, title);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
decl String:typename[WEAPONS_MAX_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// x = Array index.
|
|
|
|
new size = GetArraySize(arrayWeaponTypes);
|
|
|
|
for (new x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
// Get name of type.
|
|
|
|
RestrictWeaponTypeGetName(x, typename, sizeof(typename));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Add item to menu.
|
|
|
|
AddMenuItem(menu_weapons_types, typename, typename);
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// If there are no weapons, add an "(Empty)" line.
|
|
|
|
if (size == 0)
|
|
|
|
{
|
2009-07-28 02:02:49 +02:00
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:empty[MENU_LINE_SMALL_LENGTH];
|
2009-05-29 08:43:15 +02:00
|
|
|
Format(empty, sizeof(empty), "%t", "Menu empty");
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
AddMenuItem(menu_weapons_types, "empty", empty, ITEMDRAW_DISABLED);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Set exit back button.
|
|
|
|
SetMenuExitBackButton(menu_weapons_types, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
DisplayMenu(menu_weapons_types, client, MENU_TIME_FOREVER);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when client selects option in the weapons list menu, and handles it.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-05-29 08:43:15 +02:00
|
|
|
* @param menu_weapons_types Handle of the menu being used.
|
2009-04-12 08:04:00 +02:00
|
|
|
* @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).
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-05-29 08:43:15 +02:00
|
|
|
public WeaponsMenuTypesHandle(Handle:menu_weapons_types, MenuAction:action, client, slot)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client selected an option.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Menu slot index is = weapon type index.
|
2009-06-05 05:58:48 +02:00
|
|
|
g_iWeaponsCurType[client] = slot;
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Send weapons of the selected type in a menu to client.
|
|
|
|
WeaponsMenuTypeWeapons(client);
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client closed the menu.
|
2009-04-13 23:55:02 +02:00
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Back" button.
|
2009-04-13 23:55:02 +02:00
|
|
|
if (slot == MenuCancel_ExitBack)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-04-13 23:55:02 +02:00
|
|
|
WeaponsMenuMain(client);
|
|
|
|
}
|
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Exit" button.
|
2009-04-13 23:55:02 +02:00
|
|
|
else if (action == MenuAction_End)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
CloseHandle(menu_weapons_types);
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
/**
|
|
|
|
* Sends a list of weapons of a certain type in a menu to the client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-05-29 08:43:15 +02:00
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
WeaponsMenuTypeWeapons(client)
|
2009-04-13 23:55:02 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create menu handle.
|
2009-05-29 08:43:15 +02:00
|
|
|
new Handle:menu_weapons_typeweapons = CreateMenu(WeaponsMenuTypeWeaponsHandle);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
decl String:typename[WEAPONS_MAX_LENGTH];
|
2009-06-05 05:58:48 +02:00
|
|
|
RestrictWeaponTypeGetName(g_iWeaponsCurType[client], typename, sizeof(typename));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-08-23 17:03:14 +02:00
|
|
|
// Set translation language.
|
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
decl String:title[MENU_LINE_TITLE_LENGTH];
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:restrictall[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:unrestrictall[MENU_LINE_REG_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict types weapon type title", typename);
|
2009-06-05 05:58:48 +02:00
|
|
|
Format(restrictall, sizeof(restrictall), "%t", "Weapons menu restrict types restrict all", typename);
|
2009-06-26 09:00:05 +02:00
|
|
|
Format(unrestrictall, sizeof(unrestrictall), "%t\n ", "Weapons menu restrict types unrestrict all", typename);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Draw items as selectable only if not all weapons within the type are restricted or unrestricted.
|
2009-07-28 02:02:49 +02:00
|
|
|
SetMenuTitle(menu_weapons_typeweapons, title);
|
2009-06-05 05:58:48 +02:00
|
|
|
AddMenuItem(menu_weapons_typeweapons, "restrictall", restrictall, MenuGetItemDraw(!RestrictIsTypeUniform(true, g_iWeaponsCurType[client])));
|
|
|
|
AddMenuItem(menu_weapons_typeweapons, "unrestrictall", unrestrictall, MenuGetItemDraw(!RestrictIsTypeUniform(false, g_iWeaponsCurType[client])));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:typeweapon[MENU_LINE_SMALL_LENGTH];
|
|
|
|
decl String:display[MENU_LINE_SMALL_LENGTH + 2]; // +2 to allow room for the [ ] if its restricted.
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get an array populated with all weapons of the given type.
|
|
|
|
new Handle:arrayTypeWeapons;
|
2009-06-05 05:58:48 +02:00
|
|
|
new count = RestrictGetTypeWeapons(g_iWeaponsCurType[client], arrayTypeWeapons);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// x = Array index.
|
2009-05-29 08:43:15 +02:00
|
|
|
for (new x = 0; x < count; x++)
|
2009-04-13 23:55:02 +02:00
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get weapon index to check restricted status of.
|
|
|
|
new weaponindex = GetArrayCell(arrayTypeWeapons, x);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get name of weapon.
|
|
|
|
WeaponsGetName(weaponindex, typeweapon, sizeof(typeweapon));
|
|
|
|
strcopy(display, sizeof(display), typeweapon);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
if (RestrictIsWeaponRestricted(weaponindex))
|
2009-04-13 23:55:02 +02:00
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
Format(display, sizeof(display), "[%s]", typeweapon);
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Disable option if it isn't toggleable.
|
|
|
|
AddMenuItem(menu_weapons_typeweapons, typeweapon, display, MenuGetItemDraw(WeaponsGetToggleable(weaponindex)));
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Destroy the array handle.
|
|
|
|
CloseHandle(arrayTypeWeapons);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Set menu back button.
|
|
|
|
SetMenuExitBackButton(menu_weapons_typeweapons, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Display menu to client.
|
|
|
|
DisplayMenu(menu_weapons_typeweapons, client, MENU_TIME_FOREVER);
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when client selects option in the weapon group menu, and handles it.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-05-29 08:43:15 +02:00
|
|
|
* @param menu_weapons_typeweapons 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).
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-05-29 08:43:15 +02:00
|
|
|
public WeaponsMenuTypeWeaponsHandle(Handle:menu_weapons_typeweapons, MenuAction:action, client, slot)
|
2009-04-13 23:55:02 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client selected an option.
|
2009-04-13 23:55:02 +02:00
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get name of current weapon type.
|
|
|
|
decl String:typename[WEAPONS_MAX_LENGTH];
|
2009-06-05 05:58:48 +02:00
|
|
|
RestrictWeaponTypeGetName(g_iWeaponsCurType[client], typename, sizeof(typename));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
new RestrictQuery:query;
|
|
|
|
new bool:single;
|
|
|
|
new bool:restrict;
|
|
|
|
decl String:returntarget[WEAPONS_MAX_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-13 23:55:02 +02:00
|
|
|
switch(slot)
|
2016-02-06 00:47:47 +01:00
|
|
|
{
|
2009-04-13 23:55:02 +02:00
|
|
|
case 0:
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Restrict all weapons of this type.
|
|
|
|
restrict = true;
|
|
|
|
query = RestrictWeapon(true, typename, single, returntarget, sizeof(returntarget));
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Unrestrict all weapons of this type.
|
|
|
|
restrict = false;
|
|
|
|
query = RestrictWeapon(false, typename, single, returntarget, sizeof(returntarget));
|
2009-04-13 23:55:02 +02:00
|
|
|
}
|
|
|
|
default:
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get weappon name.
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:typeweapon[MENU_LINE_REG_LENGTH];
|
2009-05-29 08:43:15 +02:00
|
|
|
GetMenuItem(menu_weapons_typeweapons, slot, typeweapon, sizeof(typeweapon));
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Get weapon index.
|
|
|
|
new weaponindex = WeaponsNameToIndex(typeweapon);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// If weapon index is -1, then something went very wrong.
|
|
|
|
if (weaponindex == -1)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
CloseHandle(menu_weapons_typeweapons);
|
2009-06-05 05:58:48 +02:00
|
|
|
return;
|
2009-05-29 08:43:15 +02:00
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// If weapon isn't restricted, then restrict it.
|
|
|
|
if (!RestrictIsWeaponRestricted(weaponindex))
|
|
|
|
{
|
|
|
|
// Restrict this weapon.
|
|
|
|
restrict = true;
|
|
|
|
query = RestrictWeapon(true, typeweapon, single, returntarget, sizeof(returntarget));
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
2009-04-13 23:55:02 +02:00
|
|
|
else
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Unrestrict this weapon.
|
|
|
|
restrict = false;
|
|
|
|
query = RestrictWeapon(false, typeweapon, single, returntarget, sizeof(returntarget));
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Print query response.
|
|
|
|
RestrictPrintQueryResponse(client, query, single, restrict, returntarget);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Resend menu.
|
2009-05-29 08:43:15 +02:00
|
|
|
WeaponsMenuTypeWeapons(client);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client closed the menu.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Back" button.
|
2009-04-12 08:04:00 +02:00
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
WeaponsMenuTypes(client);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Exit" button.
|
2009-04-12 08:04:00 +02:00
|
|
|
else if (action == MenuAction_End)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
CloseHandle(menu_weapons_typeweapons);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
2009-04-14 01:29:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2009-05-29 08:43:15 +02:00
|
|
|
* Sends ZMarket options menu to client.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-04-14 01:29:24 +02:00
|
|
|
* @param client The client index.
|
2009-05-29 08:43:15 +02:00
|
|
|
*/
|
|
|
|
WeaponsMenuZMarket(client)
|
2009-04-14 01:29:24 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create menu handle.
|
2009-05-29 08:43:15 +02:00
|
|
|
new Handle:menu_weapons_market = CreateMenu(WeaponsMenuZMarketHandle);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
// Get "yes" or "no" settings from respective cvar.
|
2009-12-17 03:13:35 +01:00
|
|
|
decl String:buyzonesetting[MENU_LINE_SMALL_LENGTH];
|
2009-08-03 23:55:50 +02:00
|
|
|
ConfigBoolToSetting(GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]), buyzonesetting, sizeof(buyzonesetting), true, client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
SetGlobalTransTarget(client);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
decl String:title[MENU_LINE_TITLE_LENGTH];
|
2009-07-27 22:25:23 +02:00
|
|
|
decl String:buyzone[MENU_LINE_REG_LENGTH];
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Add options to menu.
|
2009-07-28 02:02:49 +02:00
|
|
|
Format(title, sizeof(title), "%t\n ", "Weapons menu restrict zmarket title");
|
2009-06-05 05:58:48 +02:00
|
|
|
Format(buyzone, sizeof(buyzone), "%t", "Weapons menu restrict zmarket buyzone", buyzonesetting);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-07-28 02:02:49 +02:00
|
|
|
SetMenuTitle(menu_weapons_market, title);
|
2009-05-29 08:43:15 +02:00
|
|
|
AddMenuItem(menu_weapons_market, "buyzone", buyzone);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Create a "Back" button to the weapons main menu.
|
2009-04-14 01:29:24 +02:00
|
|
|
SetMenuExitBackButton(menu_weapons_market, true);
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-14 01:29:24 +02:00
|
|
|
// Send menu
|
|
|
|
DisplayMenu(menu_weapons_market, client, MENU_TIME_FOREVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when client selects option in the weapons main menu, and handles it.
|
2016-02-06 00:47:47 +01:00
|
|
|
*
|
2009-05-29 08:43:15 +02:00
|
|
|
* @param menu_weapons_market Handle of the menu being used.
|
2009-04-14 01:29:24 +02:00
|
|
|
* @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).
|
2016-02-06 00:47:47 +01:00
|
|
|
*/
|
2009-05-29 08:43:15 +02:00
|
|
|
public WeaponsMenuZMarketHandle(Handle:menu_weapons_market, MenuAction:action, client, slot)
|
2009-04-14 01:29:24 +02:00
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client selected an option.
|
2009-04-14 01:29:24 +02:00
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
switch(slot)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Buyzone.
|
2009-04-14 01:29:24 +02:00
|
|
|
case 0:
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Toggle cvar.
|
|
|
|
new bool:zmarketbuyzone = GetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE]);
|
|
|
|
SetConVarBool(g_hCvarsList[CVAR_WEAPONS_ZMARKET_BUYZONE], !zmarketbuyzone);
|
2009-04-14 01:29:24 +02:00
|
|
|
}
|
|
|
|
}
|
2016-02-06 00:47:47 +01:00
|
|
|
|
2009-04-15 09:42:12 +02:00
|
|
|
// Resend menu.
|
2009-05-29 08:43:15 +02:00
|
|
|
WeaponsMenuZMarket(client);
|
2009-04-14 01:29:24 +02:00
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client closed the menu.
|
2009-04-14 01:29:24 +02:00
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Back" button.
|
2009-04-14 01:29:24 +02:00
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
WeaponsMenuMain(client);
|
|
|
|
}
|
|
|
|
}
|
2009-04-15 09:42:12 +02:00
|
|
|
// Client hit "Exit" button.
|
2009-04-14 01:29:24 +02:00
|
|
|
else if (action == MenuAction_End)
|
|
|
|
{
|
|
|
|
CloseHandle(menu_weapons_market);
|
|
|
|
}
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|