2009-04-29 01:58:41 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2008-10-04 22:59:11 +02:00
|
|
|
* Zombie:Reloaded
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
2009-05-06 02:28:09 +02:00
|
|
|
* File: menu.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Base menu functions for the plugin.
|
2009-04-29 01:58:41 +02:00
|
|
|
*
|
|
|
|
* ============================================================================
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* Show main menu to client.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
|
|
|
MenuMain(client)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Create menu handle.
|
|
|
|
new Handle:menu_main = CreateMenu(MenuMainHandle);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Make client global translations target.
|
2008-10-04 22:59:11 +02:00
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Set menu title.
|
2009-05-09 17:45:19 +02:00
|
|
|
SetMenuTitle(menu_main, "%t\n ", "Menu main title");
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Initialize menu lines.
|
|
|
|
decl String:zadmin[64];
|
|
|
|
decl String:zclass[64];
|
|
|
|
decl String:zspawn[64];
|
|
|
|
decl String:ztele[64];
|
|
|
|
decl String:zhp[64];
|
|
|
|
decl String:zmarket[64];
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Translate each line into client's language.
|
2009-05-08 04:57:21 +02:00
|
|
|
Format(zadmin, sizeof(zadmin), "%t", "Menu main zadmin", SAYHOOKS_KEYWORD_ZMENU);
|
|
|
|
Format(zclass, sizeof(zclass), "%t", "Menu main zclass", SAYHOOKS_KEYWORD_ZADMIN);
|
|
|
|
Format(zspawn, sizeof(zspawn), "%t", "Menu main zspawn", SAYHOOKS_KEYWORD_ZCLASS);
|
|
|
|
Format(ztele, sizeof(ztele), "%t", "Menu main ztele", SAYHOOKS_KEYWORD_ZTELE);
|
|
|
|
Format(zhp, sizeof(zhp), "%t", "Menu main zhp", SAYHOOKS_KEYWORD_ZHP);
|
|
|
|
Format(zmarket, sizeof(zmarket), "%t", "Menu main zmarket", SAYHOOKS_KEYWORD_ZMARKET);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Add items to menu.
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Disable option if client isn't an admin.
|
|
|
|
new bool:admin = ZRIsClientAdmin(client);
|
|
|
|
AddMenuItem(menu_main, "zadmin", zadmin, MenuGetItemDraw(admin));
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
AddMenuItem(menu_main, "zclass", zclass);
|
2008-10-04 22:59:11 +02:00
|
|
|
AddMenuItem(menu_main, "zspawn", zspawn);
|
|
|
|
AddMenuItem(menu_main, "ztele", ztele);
|
|
|
|
AddMenuItem(menu_main, "zhp", zhp);
|
2009-05-29 08:43:15 +02:00
|
|
|
AddMenuItem(menu_main, "zmarket", zmarket);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
// Display menu to client.
|
2008-10-04 22:59:11 +02:00
|
|
|
DisplayMenu(menu_main, client, MENU_TIME_FOREVER);
|
|
|
|
}
|
|
|
|
|
2009-04-29 01:58:41 +02:00
|
|
|
/**
|
|
|
|
* Menu callback (main)
|
|
|
|
* Redirects client to selected option's handle code.
|
|
|
|
*
|
|
|
|
* @param menu The menu handle.
|
|
|
|
* @param action Action client is doing in menu.
|
|
|
|
* @param client The client index.
|
|
|
|
* @param slot The menu slot selected. (starting from 0)
|
|
|
|
*/
|
|
|
|
public MenuMainHandle(Handle:menu, MenuAction:action, client, slot)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Client selected an option.
|
2008-10-04 22:59:11 +02:00
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Create variable to possible resend menu later.
|
|
|
|
new bool:resend = true;
|
|
|
|
|
2008-10-04 22:59:11 +02:00
|
|
|
switch(slot)
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Selected zadmin.
|
2009-04-15 23:40:45 +02:00
|
|
|
case 0:
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Copy return to resend variable.
|
|
|
|
resend = !ZRAdminMenu(client);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-30 07:36:57 +02:00
|
|
|
// Select zclass.
|
2009-04-15 23:40:45 +02:00
|
|
|
case 1:
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Send class menu
|
2009-04-15 23:40:45 +02:00
|
|
|
ClassMenuMain(client);
|
2009-04-29 01:58:41 +02:00
|
|
|
|
|
|
|
// Don't resend this menu.
|
|
|
|
resend = false;
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-30 07:36:57 +02:00
|
|
|
// Select zspawn.
|
2009-04-15 23:40:45 +02:00
|
|
|
case 2:
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Send zspawn command from client.
|
|
|
|
ZSpawnClient(client);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-30 07:36:57 +02:00
|
|
|
// Select ztele.
|
|
|
|
case 3:
|
2009-03-29 22:04:47 +02:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
// Copy return to resend variable.
|
2009-05-05 06:56:34 +02:00
|
|
|
resend = !ZTeleClient(client);
|
2009-03-29 22:04:47 +02:00
|
|
|
}
|
2009-04-30 07:36:57 +02:00
|
|
|
// Select zhp.
|
|
|
|
case 4:
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
2009-04-16 01:18:08 +02:00
|
|
|
// Toggle ZHP.
|
|
|
|
ZHPToggle(client);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-30 07:36:57 +02:00
|
|
|
// Select zmarket.
|
|
|
|
case 5:
|
|
|
|
{
|
2009-06-05 05:58:48 +02:00
|
|
|
// Send ZMarket menu.
|
|
|
|
resend = !ZMarketMenuTypes(client);
|
2009-04-30 07:36:57 +02:00
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-29 01:58:41 +02:00
|
|
|
|
|
|
|
// Resend is still true, then resend menu.
|
|
|
|
if (resend)
|
|
|
|
{
|
|
|
|
MenuMain(client);
|
|
|
|
}
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-29 01:58:41 +02:00
|
|
|
// Client exited menu.
|
2008-10-04 22:59:11 +02:00
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
CloseHandle(menu);
|
2008-10-04 22:59:11 +02:00
|
|
|
}
|
2009-04-29 01:58:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Return itemdraw flag for SM menus.
|
|
|
|
*
|
|
|
|
* @param condition If this is true, item will be drawn normally.
|
|
|
|
*/
|
|
|
|
MenuGetItemDraw(bool:condition)
|
|
|
|
{
|
|
|
|
return condition ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
2009-05-01 11:22:45 +02:00
|
|
|
}
|