2009-05-06 02:28:09 +02:00
|
|
|
/*
|
|
|
|
* ============================================================================
|
|
|
|
*
|
2008-10-11 17:17:51 +02:00
|
|
|
* Zombie:Reloaded
|
2009-05-06 02:28:09 +02:00
|
|
|
*
|
2009-06-12 05:51:26 +02:00
|
|
|
* File: zadmin.inc
|
|
|
|
* Type: Core
|
|
|
|
* Description: Handle admin functions and menus.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2009 Greyscale, Richard Helgeby
|
|
|
|
*
|
|
|
|
* 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
|
|
|
*
|
|
|
|
* ============================================================================
|
2008-10-11 17:17:51 +02:00
|
|
|
*/
|
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
/**
|
|
|
|
* Create commands specific to ZAdmin.
|
|
|
|
*/
|
|
|
|
ZAdminOnCommandsCreate()
|
|
|
|
{
|
|
|
|
// Register ZAdmin command.
|
|
|
|
RegConsoleCmd(SAYHOOKS_KEYWORD_ZADMIN, ZAdminCommand, "Opens ZR admin menu.");
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Command callback (zadmin)
|
|
|
|
* Opens ZR admin menu.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
* @param argc Argument count.
|
|
|
|
*/
|
|
|
|
public Action:ZAdminCommand(client, argc)
|
|
|
|
{
|
|
|
|
// If client is console, then stop and tell them this feature is for players only.
|
|
|
|
if (ZRIsConsole(client))
|
|
|
|
{
|
|
|
|
TranslationPrintToServer("Must be player");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Send admin menu.
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
|
|
|
|
// This stops the "Unknown command" message in client's console.
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main admin menu.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
2009-03-29 22:04:47 +02:00
|
|
|
bool:ZRAdminMenu(client)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
2009-06-17 23:32:46 +02:00
|
|
|
// If client isn't an admin, then stop.
|
2009-04-16 03:57:46 +02:00
|
|
|
if (!ZRIsClientAdmin(client))
|
2009-03-29 22:04:47 +02:00
|
|
|
{
|
2009-05-14 09:32:01 +02:00
|
|
|
TranslationPrintToChat(client, "Must be admin");
|
2009-03-29 22:04:47 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Create menu handle.
|
2009-06-25 08:57:39 +02:00
|
|
|
new Handle:menu_zadmin = CreateMenu(ZRAdminMenuHandle);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
// Set translation target as the client.
|
2009-03-29 22:04:47 +02:00
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
2009-06-25 08:57:39 +02:00
|
|
|
SetMenuTitle(menu_zadmin, "%t\n ", "ZAdmin main title");
|
2009-03-29 22:04:47 +02:00
|
|
|
|
2009-06-18 02:09:55 +02:00
|
|
|
decl String:classmultipliers[64];
|
2009-05-29 08:43:15 +02:00
|
|
|
//decl String:zspawn[64];
|
|
|
|
//decl String:ztele[64];
|
2009-04-12 08:04:00 +02:00
|
|
|
decl String:weapons[64];
|
2009-06-25 08:57:39 +02:00
|
|
|
decl String:infect[64];
|
2009-05-29 08:43:15 +02:00
|
|
|
//decl String:logflags[64];
|
|
|
|
|
2009-06-25 08:57:39 +02:00
|
|
|
Format(classmultipliers, sizeof(classmultipliers), "%t", "ZAdmin main class multipliers");
|
|
|
|
Format(weapons, sizeof(weapons), "%t", "ZAdmin main weapons");
|
|
|
|
Format(infect, sizeof(infect), "%t", "ZAdmin main zombie");
|
2009-05-29 08:43:15 +02:00
|
|
|
//Format(zspawn, sizeof(zspawn), "%t", "!zadmin main spawn");
|
|
|
|
//Format(ztele, sizeof(ztele), "%t", "!zadmin main tele");
|
|
|
|
//Format(logflags, sizeof(logflags), "%t", "!zadmin main logflags");
|
|
|
|
|
2009-06-25 08:57:39 +02:00
|
|
|
AddMenuItem(menu_zadmin, "classmultipliers", classmultipliers);
|
|
|
|
AddMenuItem(menu_zadmin, "weapons", weapons);
|
|
|
|
AddMenuItem(menu_zadmin, "infect", infect);
|
2009-05-29 08:43:15 +02:00
|
|
|
//AddMenuItem(menu_zadmin, "zspawn", zspawn);
|
|
|
|
//AddMenuItem(menu_zadmin, "ztele", ztele, ITEMDRAW_DISABLED);
|
|
|
|
//AddMenuItem(menu_zadmin, "logflags", logflags);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Set "Back" button.
|
2009-06-25 08:57:39 +02:00
|
|
|
SetMenuExitBackButton(menu_zadmin, true);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Send menu to client.
|
2009-06-25 08:57:39 +02:00
|
|
|
DisplayMenu(menu_zadmin, client, MENU_TIME_FOREVER);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
|
|
|
return true;
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
|
|
|
|
2009-06-17 23:32:46 +02:00
|
|
|
/**
|
|
|
|
* Menu callback (zadmin)
|
|
|
|
* Handles options selected in the admin menu.
|
|
|
|
*
|
|
|
|
* @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)
|
|
|
|
*/
|
2009-06-25 08:57:39 +02:00
|
|
|
public ZRAdminMenuHandle(Handle:menu_zadmin, MenuAction:action, client, slot)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
2009-06-08 06:05:50 +02:00
|
|
|
// Create variable to possible resend menu later.
|
|
|
|
new bool:resend = true;
|
|
|
|
|
2008-10-11 17:17:51 +02:00
|
|
|
switch(slot)
|
|
|
|
{
|
2009-06-25 08:57:39 +02:00
|
|
|
// Class multipliers.
|
2008-10-11 17:17:51 +02:00
|
|
|
case 0:
|
2009-06-18 02:09:55 +02:00
|
|
|
{
|
|
|
|
resend = !ClassTeamSelect(client);
|
|
|
|
}
|
|
|
|
// Weapon management.
|
|
|
|
case 1:
|
2008-12-26 23:03:29 +01:00
|
|
|
{
|
2009-06-08 06:05:50 +02:00
|
|
|
resend = !WeaponsMenuMain(client);
|
2008-12-26 23:03:29 +01:00
|
|
|
}
|
2009-06-25 08:57:39 +02:00
|
|
|
// Zombie management.
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
// We're not resending this menu.
|
|
|
|
resend = false;
|
|
|
|
|
|
|
|
// Send list of clients to infect.
|
|
|
|
InfectMenuClients(client);
|
|
|
|
}
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
2009-05-29 08:43:15 +02:00
|
|
|
|
2009-06-08 06:05:50 +02:00
|
|
|
// Re-send menu if selection failed.
|
|
|
|
if (resend)
|
|
|
|
{
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
}
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
2009-03-29 22:04:47 +02:00
|
|
|
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
2009-05-29 08:43:15 +02:00
|
|
|
// Exit back to main menu.
|
2009-06-22 06:08:26 +02:00
|
|
|
ZMenuMain(client);
|
2009-03-29 22:04:47 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (action == MenuAction_End)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
2009-06-25 08:57:39 +02:00
|
|
|
CloseHandle(menu_zadmin);
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
|
|
|
}
|