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-18 02:09:55 +02:00
|
|
|
new Handle:menu = 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-18 02:09:55 +02:00
|
|
|
SetMenuTitle(menu, "%t\n ", "!zadmin 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:infect[64];
|
|
|
|
//decl String:zspawn[64];
|
|
|
|
//decl String:ztele[64];
|
2009-04-12 08:04:00 +02:00
|
|
|
decl String:weapons[64];
|
2009-05-29 08:43:15 +02:00
|
|
|
//decl String:logflags[64];
|
|
|
|
|
2009-06-18 02:09:55 +02:00
|
|
|
Format(classmultipliers, sizeof(classmultipliers), "%t", "!zadmin class multipliers");
|
2009-05-29 08:43:15 +02:00
|
|
|
//Format(infect, sizeof(infect), "%t", "!zadmin main infect");
|
|
|
|
//Format(zspawn, sizeof(zspawn), "%t", "!zadmin main spawn");
|
|
|
|
//Format(ztele, sizeof(ztele), "%t", "!zadmin main tele");
|
2009-06-18 02:09:55 +02:00
|
|
|
Format(weapons, sizeof(weapons), "%t", "!zadmin weapons");
|
2009-05-29 08:43:15 +02:00
|
|
|
//Format(logflags, sizeof(logflags), "%t", "!zadmin main logflags");
|
|
|
|
|
2009-06-18 02:09:55 +02:00
|
|
|
AddMenuItem(menu, "classmultipliers", classmultipliers);
|
2009-05-29 08:43:15 +02:00
|
|
|
//AddMenuItem(menu_zadmin, "infect", infect);
|
|
|
|
//AddMenuItem(menu_zadmin, "zspawn", zspawn);
|
|
|
|
//AddMenuItem(menu_zadmin, "ztele", ztele, ITEMDRAW_DISABLED);
|
2009-06-18 02:09:55 +02:00
|
|
|
AddMenuItem(menu, "weapons", weapons);
|
2009-05-29 08:43:15 +02:00
|
|
|
//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-18 02:09:55 +02:00
|
|
|
SetMenuExitBackButton(menu, true);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
2009-05-29 08:43:15 +02:00
|
|
|
// Send menu to client.
|
2009-06-18 02:09:55 +02:00
|
|
|
DisplayMenu(menu, client, MENU_TIME_FOREVER);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
|
|
|
return true;
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
|
|
|
|
2009-06-18 02:09:55 +02:00
|
|
|
public ZRAdminMenuHandle(Handle:menu, MenuAction:action, client, slot)
|
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)
|
|
|
|
*/
|
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)
|
|
|
|
{
|
|
|
|
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
|
|
|
}
|
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-18 02:09:55 +02:00
|
|
|
CloseHandle(menu);
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*ZRInfectMenu(client)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
new Handle:menu_infect = CreateMenu(ZRInfectHandle);
|
|
|
|
|
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
|
|
|
SetMenuTitle(menu_infect, "%t\n ", "!zadmin infect title");
|
|
|
|
|
|
|
|
AddTargetsToMenu(menu_infect, client, true, true);
|
|
|
|
|
|
|
|
SetMenuExitBackButton(menu_infect, true);
|
|
|
|
|
|
|
|
DisplayMenu(menu_infect, client, MENU_TIME_FOREVER);
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2008-10-11 17:17:51 +02:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*public ZRInfectHandle(Handle:menu_infect, MenuAction:action, client, slot)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
decl String:info[32];
|
|
|
|
new userid, target;
|
|
|
|
|
2009-03-29 22:04:47 +02:00
|
|
|
GetMenuItem(menu_infect, slot, info, sizeof(info));
|
2008-10-11 17:17:51 +02:00
|
|
|
userid = StringToInt(info);
|
|
|
|
|
|
|
|
if ((target = GetClientOfUserId(userid)) == 0)
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[ZR] Player no longer available");
|
|
|
|
}
|
|
|
|
else if (!CanUserTarget(client, target))
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[ZR] Unable to target player");
|
|
|
|
}
|
|
|
|
else if (!IsPlayerAlive(target))
|
|
|
|
{
|
|
|
|
ReplyToCommand(client, "[ZR] Player is dead");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
decl String:name[64];
|
|
|
|
GetClientName(target, name, sizeof(name));
|
2009-06-15 21:43:06 +02:00
|
|
|
InfectHumanToZombie(target);
|
2008-10-11 17:17:51 +02:00
|
|
|
ShowActivity2(client, "[ZR] ", "Infected %s", name);
|
|
|
|
ZRInfectMenu(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
CloseHandle(menu_infect);
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2008-10-11 17:17:51 +02:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*ZRSpawnAll(client)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
2009-04-16 03:57:46 +02:00
|
|
|
// x = client index.
|
|
|
|
for (new x = 1; x < MaxClients; x++)
|
2008-10-11 17:17:51 +02:00
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
if (IsClientInGame(x))
|
2008-11-15 19:11:36 +01:00
|
|
|
{
|
2009-04-29 01:58:41 +02:00
|
|
|
ZSpawnClient(x);
|
2008-11-15 19:11:36 +01:00
|
|
|
}
|
2008-10-11 17:17:51 +02:00
|
|
|
}
|
2008-11-12 16:03:40 +01:00
|
|
|
ZRAdminMenu(client);
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2008-10-11 17:17:51 +02:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*ZRZTeleMenu(client)
|
2008-12-26 23:03:29 +01:00
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
new Handle:menu_ztele = CreateMenu(ZRTeleHandle);
|
|
|
|
|
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
|
|
|
SetMenuTitle(menu_ztele, "%t\n ", "!zadmin ztele title");
|
2008-12-26 23:03:29 +01:00
|
|
|
|
2009-03-29 22:04:47 +02:00
|
|
|
decl String:ztele_spawntele[64];
|
|
|
|
decl String:ztele_abort[64];
|
|
|
|
decl String:ztele_save[64];
|
|
|
|
decl String:ztele_tele[64];
|
2008-12-26 23:03:29 +01:00
|
|
|
|
2009-03-29 22:04:47 +02:00
|
|
|
Format(ztele_spawntele, sizeof(ztele_spawntele), "%t", "!zadmin ztele spawn tele");
|
|
|
|
Format(ztele_abort, sizeof(ztele_abort), "%t", "!zadmin ztele abort");
|
|
|
|
Format(ztele_save, sizeof(ztele_save), "%t", "!zadmin ztele save");
|
|
|
|
Format(ztele_tele, sizeof(ztele_tele), "%t", "!zadmin ztele tele");
|
2008-12-26 23:03:29 +01:00
|
|
|
|
2009-03-29 22:04:47 +02:00
|
|
|
AddMenuItem(menu_ztele, "ztele_spawntele", ztele_spawntele);
|
|
|
|
AddMenuItem(menu_ztele, "ztele_abort", ztele_abort);
|
|
|
|
AddMenuItem(menu_ztele, "ztele_save", ztele_save);
|
|
|
|
AddMenuItem(menu_ztele, "ztele_tele", ztele_tele);
|
|
|
|
|
|
|
|
SetMenuExitBackButton(menu_ztele, true);
|
|
|
|
DisplayMenu(menu_ztele, client, MENU_TIME_FOREVER);
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2008-12-26 23:03:29 +01:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*public ZRTeleHandle(Handle:menu_ztele , MenuAction:action, client, slot)
|
2008-12-26 23:03:29 +01:00
|
|
|
{
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
switch(slot)
|
|
|
|
{
|
|
|
|
case 0:
|
|
|
|
{
|
|
|
|
// Teleport player.
|
|
|
|
}
|
|
|
|
case 1:
|
|
|
|
{
|
|
|
|
// Abort teleport.
|
|
|
|
}
|
|
|
|
case 2:
|
|
|
|
{
|
|
|
|
// Save location.
|
|
|
|
}
|
|
|
|
case 3:
|
|
|
|
{
|
|
|
|
// Teleport to location.
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
CloseHandle(menu_ztele);
|
2008-12-26 23:03:29 +01:00
|
|
|
}
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2008-12-26 23:03:29 +01:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*ZRLogFlagsMenu(client)
|
2009-01-31 20:48:56 +01:00
|
|
|
{
|
2009-03-29 22:04:47 +02:00
|
|
|
new Handle:menu_log_flags = CreateMenu(ZRLogFlagsMenuHandle);
|
|
|
|
|
|
|
|
SetGlobalTransTarget(client);
|
|
|
|
|
|
|
|
SetMenuTitle(menu_log_flags, "%t\n ", "!zadmin log flags title");
|
|
|
|
|
2009-05-14 09:32:01 +02:00
|
|
|
//new client_flags = GetUserFlagBits(client);
|
|
|
|
//new item_state = (client_flags & ADMFLAG_ROOT) ? ITEMDRAW_DEFAULT : ITEMDRAW_DISABLED;
|
2009-02-13 22:57:02 +01:00
|
|
|
|
2009-05-14 09:32:01 +02:00
|
|
|
//decl String:z_log_core[64];
|
|
|
|
|
|
|
|
//Format(z_log_core, sizeof(z_log_core), "Log core events (%d)", LogCheckFlag(LOG_CORE_EVENTS));
|
|
|
|
|
|
|
|
//AddMenuItem(menu_log_flags, z_log_core, z_log_core, item_state);
|
2009-03-29 22:04:47 +02:00
|
|
|
|
|
|
|
SetMenuExitBackButton(menu_log_flags, true);
|
|
|
|
DisplayMenu(menu_log_flags, client, MENU_TIME_FOREVER);
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|
2009-01-31 20:48:56 +01:00
|
|
|
|
2009-05-30 04:42:23 +02:00
|
|
|
/*public ZRLogFlagsMenuHandle(Handle:menu_log_flags, MenuAction:action, client, slot)
|
2009-01-31 20:48:56 +01:00
|
|
|
{
|
|
|
|
if (action == MenuAction_Select)
|
|
|
|
{
|
|
|
|
switch(slot)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_Cancel)
|
|
|
|
{
|
|
|
|
if (slot == MenuCancel_ExitBack)
|
|
|
|
{
|
|
|
|
ZRAdminMenu(client);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (action == MenuAction_End)
|
|
|
|
{
|
2009-04-15 03:24:02 +02:00
|
|
|
CloseHandle(menu_log_flags);
|
2009-01-31 20:48:56 +01:00
|
|
|
}
|
2009-05-30 04:42:23 +02:00
|
|
|
}*/
|