2009-04-12 08:04:00 +02:00
|
|
|
/**
|
|
|
|
* ====================
|
|
|
|
* Zombie:Reloaded
|
|
|
|
* File: menu_weapons.inc
|
|
|
|
* Author: Greyscale
|
|
|
|
* ====================
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Weapons Menus
|
|
|
|
*/
|
|
|
|
enum WeaponsMenu
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
Weapon,
|
|
|
|
WeaponGroup,
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Array to store the client's current weapon menu
|
|
|
|
*/
|
2009-04-13 06:00:58 +02:00
|
|
|
new WeaponsMenu:curMenuWeapons[MAXPLAYERS + 1];
|
2009-04-12 08:04:00 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends main weapon menu to client.
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
WeaponsMenuMain(client)
|
|
|
|
{
|
|
|
|
// Create menu handle
|
|
|
|
new Handle:menu_weapons_main = CreateMenu(WeaponsMenuMainHandle);
|
|
|
|
|
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
|
|
|
SetMenuTitle(menu_weapons_main, "%t\n ", "Weapons menu main title");
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
decl String:toggleweaponrestriction[64];
|
|
|
|
decl String:togglewgrouprestriction[64];
|
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
decl String:zmarket[64];
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
Format(toggleweaponrestriction, sizeof(toggleweaponrestriction), "%t", "Weapons menu main toggle weapon restrict");
|
|
|
|
Format(togglewgrouprestriction, sizeof(togglewgrouprestriction), "%t", "Weapons menu main toggle weapon group restrict");
|
2009-04-12 08:04:00 +02:00
|
|
|
Format(zmarket, sizeof(zmarket), "%t", "Weapons menu main market");
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
AddMenuItem(menu_weapons_main, "toggleweaponrestriction", toggleweaponrestriction);
|
|
|
|
AddMenuItem(menu_weapons_main, "togglewgrouprestriction", togglewgrouprestriction);
|
2009-04-12 08:04:00 +02:00
|
|
|
|
|
|
|
// Disable market option if market isn't installed
|
|
|
|
if (market)
|
|
|
|
{
|
|
|
|
AddMenuItem(menu_weapons_main, "zmarket", zmarket);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddMenuItem(menu_weapons_main, "zmarket", zmarket, ITEMDRAW_DISABLED);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create a "Back" button to the weapons main menu
|
|
|
|
SetMenuExitBackButton(menu_weapons_main, true);
|
|
|
|
|
|
|
|
// Send menu
|
|
|
|
DisplayMenu(menu_weapons_main, 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 WeaponsMenuMainHandle(Handle:menu_weapons_main, MenuAction:action, client, slot)
|
|
|
|
{
|
|
|
|
// Client selected an option
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
switch(slot)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
WeaponsMenuWeapons(client, Weapon);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
WeaponsMenuWeapons(client, WeaponGroup);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
// WeaponsMenuMarket(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Client closed the menu
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
// Client hit "Back" button
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Client hit "Exit" button
|
|
|
|
else if (action == MenuAction_End)
|
|
|
|
{
|
|
|
|
CloseHandle(menu_weapons_main);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Sends weapon list menu to client.
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
WeaponsMenuWeapons(client, WeaponsMenu:type)
|
|
|
|
{
|
|
|
|
// Set the current action client is performing on a weapon (see enum WeaponsMenu)
|
|
|
|
curMenuWeapons[client] = type;
|
|
|
|
|
|
|
|
// Create menu handle
|
|
|
|
new Handle:menu_weapons_weapons = CreateMenu(WeaponsMenuWeaponsHandle);
|
|
|
|
|
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
|
|
|
SetMenuTitle(menu_weapons_weapons, "%t\n ", "Weapons menu weapons title");
|
|
|
|
|
|
|
|
// If client wants to perform an action on a single weapon, show weapon list
|
2009-04-13 20:33:13 +02:00
|
|
|
if (curMenuWeapons[client] == Weapon)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
|
|
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
|
|
|
new Handle:arrayWeapons = INVALID_HANDLE;
|
|
|
|
new size = WeaponsCreateWeaponArray(arrayWeapons);
|
|
|
|
|
|
|
|
// x = Array index
|
|
|
|
for (new x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
GetArrayString(arrayWeapons, x, weapon, sizeof(weapon));
|
|
|
|
|
|
|
|
new bool:menu = WeaponsIsWeaponMenu(weapon);
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
if (RestrictIsWeaponRestricted(weapon))
|
|
|
|
{
|
|
|
|
Format(weapon, sizeof(weapon), "%s*", weapon);
|
|
|
|
}
|
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
// If weapon restriction is blocked for the menu, disable option
|
|
|
|
if (menu)
|
|
|
|
{
|
|
|
|
AddMenuItem(menu_weapons_weapons, weapon, weapon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
AddMenuItem(menu_weapons_weapons, weapon, weapon, ITEMDRAW_DISABLED);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kill the array handle
|
|
|
|
CloseHandle(arrayWeapons);
|
|
|
|
}
|
|
|
|
// If client wants to perform an action on a weapon group, show custom group list
|
2009-04-13 20:33:13 +02:00
|
|
|
else if (curMenuWeapons[client] == WeaponGroup)
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
|
|
|
decl String:weapongroup[WEAPONS_MAX_LENGTH];
|
|
|
|
new Handle:arrayWeaponGroups = INVALID_HANDLE;
|
2009-04-13 20:33:13 +02:00
|
|
|
new size = RestrictCreateGroupArray(arrayWeaponGroups);
|
2009-04-12 08:04:00 +02:00
|
|
|
|
|
|
|
// x = Array index
|
|
|
|
for (new x = 0; x < size; x++)
|
|
|
|
{
|
|
|
|
GetArrayString(arrayWeaponGroups, x, weapongroup, sizeof(weapongroup));
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
if (RestrictIsWeaponRestricted(weapongroup))
|
|
|
|
{
|
|
|
|
Format(weapongroup, sizeof(weapongroup), "%s*", weapongroup);
|
|
|
|
}
|
|
|
|
|
2009-04-12 08:04:00 +02:00
|
|
|
AddMenuItem(menu_weapons_weapons, weapongroup, weapongroup);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Kill the array handle
|
|
|
|
CloseHandle(arrayWeaponGroups);
|
|
|
|
}
|
|
|
|
|
|
|
|
SetMenuExitBackButton(menu_weapons_weapons, true);
|
|
|
|
|
|
|
|
DisplayMenu(menu_weapons_weapons, client, MENU_TIME_FOREVER);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when client selects option in the weapons list 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 WeaponsMenuWeaponsHandle(Handle:menu_weapons_weapons, MenuAction:action, client, slot)
|
|
|
|
{
|
|
|
|
// Client selected an option
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
decl String:weapon[WEAPONS_MAX_LENGTH];
|
|
|
|
GetMenuItem(menu_weapons_weapons, slot, weapon, sizeof(weapon));
|
|
|
|
|
|
|
|
new WpnRestrictQuery:output;
|
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
// Set restrict to true if were restricting a weapon/group, false if not
|
|
|
|
new bool:restrict;
|
|
|
|
if (RestrictIsWeaponGroup(weapon))
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
restrict = RestrictIsGroupRestricted(weapon);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
restrict = RestrictIsWeaponRestricted(weapon);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (restrict)
|
|
|
|
{
|
|
|
|
decl String:display[WEAPONS_MAX_LENGTH];
|
|
|
|
|
|
|
|
output = RestrictRestrict(weapon, display);
|
2009-04-12 08:04:00 +02:00
|
|
|
|
|
|
|
switch(output)
|
|
|
|
{
|
|
|
|
case Successful_Weapon:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(0, "Restrict weapon", display);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Successful_Group:
|
|
|
|
{
|
|
|
|
decl String:weaponlist[128];
|
2009-04-13 20:33:13 +02:00
|
|
|
RestrictGetGroupWeapons(display, weaponlist, sizeof(weaponlist), ", ");
|
2009-04-12 08:04:00 +02:00
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(0, "Restrict custom weapon group", display, weaponlist);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Failed_Weapon:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(client, "Restrict weapon failed", display);
|
|
|
|
}
|
|
|
|
case Failed_Group:
|
|
|
|
{
|
|
|
|
decl String:weaponlist[128];
|
|
|
|
RestrictGetGroupWeapons(display, weaponlist, sizeof(weaponlist), ", ");
|
|
|
|
|
|
|
|
ZR_PrintToChat(client, "Restrict custom weapon group failed", display, weaponlist);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Invalid:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(client, "Weapon invalid", display);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2009-04-13 20:33:13 +02:00
|
|
|
else
|
2009-04-12 08:04:00 +02:00
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
decl String:display[WEAPONS_MAX_LENGTH];
|
|
|
|
|
|
|
|
output = RestrictUnrestrict(weapon, display);
|
2009-04-12 08:04:00 +02:00
|
|
|
|
|
|
|
switch(output)
|
|
|
|
{
|
|
|
|
case Successful_Weapon:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(0, "Unrestrict weapon", display);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Successful_Group:
|
|
|
|
{
|
|
|
|
decl String:weaponlist[128];
|
2009-04-13 20:33:13 +02:00
|
|
|
RestrictGetGroupWeapons(display, weaponlist, sizeof(weaponlist), ", ");
|
2009-04-12 08:04:00 +02:00
|
|
|
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(0, "Unrestrict custom weapon group", display, weaponlist);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Failed_Weapon:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(client, "Unrestrict weapon failed", display);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
case Invalid:
|
|
|
|
{
|
2009-04-13 20:33:13 +02:00
|
|
|
ZR_PrintToChat(client, "Weapon invalid", display);
|
2009-04-12 08:04:00 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Resend menu
|
|
|
|
WeaponsMenuWeapons(client, curMenuWeapons[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_weapons);
|
|
|
|
}
|
|
|
|
}
|