2008-10-04 22:59:11 +02:00
|
|
|
/**
|
|
|
|
* vim: set ts=4 :
|
|
|
|
* =============================================================================
|
2009-04-14 23:40:48 +02:00
|
|
|
* SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
|
2008-10-04 22:59:11 +02:00
|
|
|
* =============================================================================
|
|
|
|
*
|
|
|
|
* This file is part of the SourceMod/SourcePawn SDK.
|
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify it under
|
|
|
|
* the terms of the GNU General Public License, version 3.0, as published by the
|
|
|
|
* Free Software Foundation.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*
|
|
|
|
* As a special exception, AlliedModders LLC gives you permission to link the
|
|
|
|
* code of this program (as well as its derivative works) to "Half-Life 2," the
|
|
|
|
* "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
|
|
|
|
* by the Valve Corporation. You must obey the GNU General Public License in
|
|
|
|
* all respects for all other code used. Additionally, AlliedModders LLC grants
|
|
|
|
* this exception to all derivative works. AlliedModders LLC defines further
|
|
|
|
* exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
|
|
|
|
* or <http://www.sourcemod.net/license.php>.
|
|
|
|
*
|
2009-04-14 23:40:48 +02:00
|
|
|
* Version: $Id$
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#if defined _adminmenu_included
|
|
|
|
#endinput
|
|
|
|
#endif
|
|
|
|
#define _adminmenu_included
|
|
|
|
|
|
|
|
/* Decide whether topmenus should be required */
|
|
|
|
#if !defined REQUIRE_PLUGIN
|
|
|
|
#if defined REQUIRE_EXTENSIONS
|
2010-07-25 20:58:18 +02:00
|
|
|
#define TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#undef REQUIRE_EXTENSIONS
|
|
|
|
#endif
|
2008-10-04 22:59:11 +02:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#include <topmenus>
|
|
|
|
|
|
|
|
/* Restore old REQUIRE_EXTENSIONS value if necessary */
|
|
|
|
#if defined TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#define REQUIRE_EXTENSIONS
|
|
|
|
#undef TEMP_REQUIRE_EXTENSIONS
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/** Category for player commands. */
|
2019-09-27 13:14:44 +02:00
|
|
|
#define ADMINMENU_PLAYERCOMMANDS "PlayerCommands"
|
2008-10-04 22:59:11 +02:00
|
|
|
/** Category for server commands. */
|
2019-09-27 13:14:44 +02:00
|
|
|
#define ADMINMENU_SERVERCOMMANDS "ServerCommands"
|
2008-10-04 22:59:11 +02:00
|
|
|
/** Category for voting commands. */
|
2019-09-27 13:14:44 +02:00
|
|
|
#define ADMINMENU_VOTINGCOMMANDS "VotingCommands"
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the admin menu is created and 3rd party plugins can grab
|
|
|
|
* the Handle or add categories.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param topmenu Handle to the admin menu's TopMenu.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
forward void OnAdminMenuCreated(Handle topmenu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Called when the admin menu is ready to have items added.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param topmenu Handle to the admin menu's TopMenu.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
forward void OnAdminMenuReady(Handle topmenu);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Retrieves the Handle to the admin top menu.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @return Handle to the admin menu's TopMenu,
|
|
|
|
* or INVALID_HANDLE if not created yet.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2015-03-21 15:43:24 +01:00
|
|
|
native TopMenu GetAdminTopMenu();
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds targets to an admin menu.
|
|
|
|
*
|
|
|
|
* Each client is displayed as: name (userid)
|
|
|
|
* Each item contains the userid as a string for its info.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param source_client Source client, or 0 to ignore immunity.
|
|
|
|
* @param in_game_only True to only select in-game players.
|
|
|
|
* @param alive_only True to only select alive players.
|
|
|
|
* @return Number of clients added.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int AddTargetsToMenu(Handle menu,
|
2019-09-27 13:14:44 +02:00
|
|
|
int source_client,
|
|
|
|
bool in_game_only=true,
|
|
|
|
bool alive_only=false);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Adds targets to an admin menu.
|
|
|
|
*
|
|
|
|
* Each client is displayed as: name (userid)
|
|
|
|
* Each item contains the userid as a string for its info.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param menu Menu Handle.
|
|
|
|
* @param source_client Source client, or 0 to ignore immunity.
|
|
|
|
* @param flags COMMAND_FILTER flags from commandfilters.inc.
|
|
|
|
* @return Number of clients added.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
native int AddTargetsToMenu2(Handle menu, int source_client, int flags);
|
2008-10-04 22:59:11 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Re-displays the admin menu to a client after selecting an item.
|
|
|
|
* Auto-aborts if the Handle is invalid.
|
|
|
|
*
|
2019-09-27 13:14:44 +02:00
|
|
|
* @param topmenu TopMenu Handle.
|
|
|
|
* @param client Client index.
|
|
|
|
* @return True on success, false on failure.
|
2008-10-04 22:59:11 +02:00
|
|
|
*/
|
2016-08-23 15:34:00 +02:00
|
|
|
stock bool RedisplayAdminMenu(Handle topmenu, int client)
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
if (topmenu == INVALID_HANDLE)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
return DisplayTopMenu(topmenu, client, TopMenuPosition_LastCategory);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* DO NOT EDIT BELOW THIS LINE */
|
|
|
|
|
2016-08-23 15:34:00 +02:00
|
|
|
public SharedPlugin __pl_adminmenu =
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
name = "adminmenu",
|
|
|
|
file = "adminmenu.smx",
|
|
|
|
#if defined REQUIRE_PLUGIN
|
|
|
|
required = 1,
|
|
|
|
#else
|
|
|
|
required = 0,
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
#if !defined REQUIRE_PLUGIN
|
2016-08-23 15:34:00 +02:00
|
|
|
public void __pl_adminmenu_SetNTVOptional()
|
2008-10-04 22:59:11 +02:00
|
|
|
{
|
|
|
|
MarkNativeAsOptional("GetAdminTopMenu");
|
|
|
|
MarkNativeAsOptional("AddTargetsToMenu");
|
|
|
|
MarkNativeAsOptional("AddTargetsToMenu2");
|
|
|
|
}
|
|
|
|
#endif
|