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-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.
|
2009-06-26 02:03:34 +02:00
|
|
|
ZAdminMenu(client);
|
2009-06-17 23:32:46 +02:00
|
|
|
|
|
|
|
// This stops the "Unknown command" message in client's console.
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Main admin menu.
|
|
|
|
*
|
|
|
|
* @param client The client index.
|
|
|
|
*/
|
2009-06-26 02:03:34 +02:00
|
|
|
bool:ZAdminMenu(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-26 02:03:34 +02:00
|
|
|
new Handle:menu_zadmin = CreateMenu(ZAdminMenuHandle);
|
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-07-27 22:25:23 +02:00
|
|
|
decl String:classmultipliers[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:weapons[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:hitgroups[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:infect[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:zspawn[MENU_LINE_REG_LENGTH];
|
|
|
|
decl String:ztele[MENU_LINE_REG_LENGTH];
|
2009-05-29 08:43:15 +02:00
|
|
|
|
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");
|
2009-06-26 09:00:05 +02:00
|
|
|
Format(hitgroups, sizeof(hitgroups), "%t", "ZAdmin main hitgroups");
|
2009-06-25 08:57:39 +02:00
|
|
|
Format(infect, sizeof(infect), "%t", "ZAdmin main zombie");
|
2009-06-26 02:03:34 +02:00
|
|
|
Format(zspawn, sizeof(zspawn), "%t", "ZAdmin main force zspawn");
|
|
|
|
Format(ztele, sizeof(ztele), "%t", "ZAdmin main force ztele");
|
2009-05-29 08:43:15 +02:00
|
|
|
|
2009-07-02 10:44:41 +02:00
|
|
|
// Get conditions for options.
|
2009-07-02 10:46:41 +02:00
|
|
|
new bool:hitgroupsenabled = GetConVarBool(g_hCvarsList[CVAR_HITGROUPS]);
|
2009-07-02 10:44:41 +02:00
|
|
|
|
|
|
|
// Add items to menu.
|
2009-06-25 08:57:39 +02:00
|
|
|
AddMenuItem(menu_zadmin, "classmultipliers", classmultipliers);
|
|
|
|
AddMenuItem(menu_zadmin, "weapons", weapons);
|
2009-07-02 10:46:41 +02:00
|
|
|
AddMenuItem(menu_zadmin, "hitgroups", hitgroups, MenuGetItemDraw(hitgroupsenabled));
|
2009-06-25 08:57:39 +02:00
|
|
|
AddMenuItem(menu_zadmin, "infect", infect);
|
2009-06-26 02:03:34 +02:00
|
|
|
AddMenuItem(menu_zadmin, "zspawn", zspawn);
|
|
|
|
AddMenuItem(menu_zadmin, "ztele", ztele);
|
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-26 02:03:34 +02:00
|
|
|
public ZAdminMenuHandle(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-26 09:00:05 +02:00
|
|
|
// Hitgroup management.
|
2009-06-25 08:57:39 +02:00
|
|
|
case 2:
|
2009-06-26 09:00:05 +02:00
|
|
|
{
|
|
|
|
resend = !HitgroupsMenuHitgroups(client);
|
|
|
|
}
|
|
|
|
// Zombie management.
|
|
|
|
case 3:
|
2009-06-25 08:57:39 +02:00
|
|
|
{
|
|
|
|
// We're not resending this menu.
|
|
|
|
resend = false;
|
|
|
|
|
|
|
|
// Send list of clients to infect.
|
|
|
|
InfectMenuClients(client);
|
|
|
|
}
|
2009-06-26 02:03:34 +02:00
|
|
|
// Force ZSpawn.
|
2009-06-26 09:00:05 +02:00
|
|
|
case 4:
|
2009-06-26 02:03:34 +02:00
|
|
|
{
|
|
|
|
// We're not resending this menu.
|
|
|
|
resend = false;
|
|
|
|
|
|
|
|
// Send list of clients to infect.
|
2009-07-21 22:25:11 +02:00
|
|
|
MenuClientList(client, ZSpawnForceHandle, true, false, true, "ZSpawn clients title");
|
2009-06-26 02:03:34 +02:00
|
|
|
}
|
|
|
|
// Force ZTele.
|
2009-06-26 09:00:05 +02:00
|
|
|
case 5:
|
2009-06-26 02:03:34 +02:00
|
|
|
{
|
|
|
|
// We're not resending this menu.
|
|
|
|
resend = false;
|
|
|
|
|
|
|
|
// Send list of clients to infect.
|
2009-07-21 22:25:11 +02:00
|
|
|
MenuClientList(client, ZTeleForceHandle, true, true, false, "ZTele clients title");
|
2009-06-26 02:03:34 +02:00
|
|
|
}
|
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)
|
|
|
|
{
|
2009-06-26 02:03:34 +02:00
|
|
|
ZAdminMenu(client);
|
2009-06-08 06:05:50 +02:00
|
|
|
}
|
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
|
|
|
}
|
|
|
|
}
|