1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/plugins/include/adminmenu.inc Sun Jul 06 04:49:55 2008 +0000
1.3 @@ -0,0 +1,153 @@
1.4 +/**
1.5 + * vim: set ts=4 :
1.6 + * =============================================================================
1.7 + * SourceMod (C)2004-2008 AlliedModders LLC. All rights reserved.
1.8 + * =============================================================================
1.9 + *
1.10 + * This file is part of the SourceMod/SourcePawn SDK.
1.11 + *
1.12 + * This program is free software; you can redistribute it and/or modify it under
1.13 + * the terms of the GNU General Public License, version 3.0, as published by the
1.14 + * Free Software Foundation.
1.15 + *
1.16 + * This program is distributed in the hope that it will be useful, but WITHOUT
1.17 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
1.18 + * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
1.19 + * details.
1.20 + *
1.21 + * You should have received a copy of the GNU General Public License along with
1.22 + * this program. If not, see <http://www.gnu.org/licenses/>.
1.23 + *
1.24 + * As a special exception, AlliedModders LLC gives you permission to link the
1.25 + * code of this program (as well as its derivative works) to "Half-Life 2," the
1.26 + * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
1.27 + * by the Valve Corporation. You must obey the GNU General Public License in
1.28 + * all respects for all other code used. Additionally, AlliedModders LLC grants
1.29 + * this exception to all derivative works. AlliedModders LLC defines further
1.30 + * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
1.31 + * or <http://www.sourcemod.net/license.php>.
1.32 + *
1.33 + * Version: $Id$
1.34 + */
1.35 +
1.36 +#if defined _adminmenu_included
1.37 + #endinput
1.38 +#endif
1.39 +#define _adminmenu_included
1.40 +
1.41 +/* Decide whether topmenus should be required */
1.42 +#if !defined REQUIRE_PLUGIN
1.43 + #if defined REQUIRE_EXTENSIONS
1.44 + #define TEMP_REQUIRE_EXTENSIONS
1.45 + #undef REQUIRE_EXTENSIONS
1.46 +#endif
1.47 +
1.48 +#include <topmenus>
1.49 +
1.50 +/* Restore old REQUIRE_EXTENSIONS value if necessary */
1.51 +#if defined TEMP_REQUIRE_EXTENSIONS
1.52 + #define REQUIRE_EXTENSIONS
1.53 + #undef TEMP_REQUIRE_EXTENSIONS
1.54 +#endif
1.55 +
1.56 +/** Category for player commands. */
1.57 +#define ADMINMENU_PLAYERCOMMANDS "PlayerCommands"
1.58 +/** Category for server commands. */
1.59 +#define ADMINMENU_SERVERCOMMANDS "ServerCommands"
1.60 +/** Category for voting commands. */
1.61 +#define ADMINMENU_VOTINGCOMMANDS "VotingCommands"
1.62 +
1.63 +/**
1.64 + * Called when the admin menu is created and 3rd party plugins can grab
1.65 + * the Handle or add categories.
1.66 + *
1.67 + * @param topmenu Handle to the admin menu's TopMenu.
1.68 + * @noreturn
1.69 + */
1.70 +forward OnAdminMenuCreated(Handle:topmenu);
1.71 +
1.72 +/**
1.73 + * Called when the admin menu is ready to have items added.
1.74 + *
1.75 + * @param topmenu Handle to the admin menu's TopMenu.
1.76 + * @noreturn
1.77 + */
1.78 +forward OnAdminMenuReady(Handle:topmenu);
1.79 +
1.80 +/**
1.81 + * Retrieves the Handle to the admin top menu.
1.82 + *
1.83 + * @return Handle to the admin menu's TopMenu,
1.84 + * or INVALID_HANDLE if not created yet.
1.85 + */
1.86 +native Handle:GetAdminTopMenu();
1.87 +
1.88 +/**
1.89 + * Adds targets to an admin menu.
1.90 + *
1.91 + * Each client is displayed as: name (userid)
1.92 + * Each item contains the userid as a string for its info.
1.93 + *
1.94 + * @param menu Menu Handle.
1.95 + * @param source_client Source client, or 0 to ignore immunity.
1.96 + * @param in_game_only True to only select in-game players.
1.97 + * @param alive_only True to only select alive players.
1.98 + * @return Number of clients added.
1.99 + */
1.100 +native AddTargetsToMenu(Handle:menu,
1.101 + source_client,
1.102 + bool:in_game_only=true,
1.103 + bool:alive_only=false);
1.104 +
1.105 +/**
1.106 + * Adds targets to an admin menu.
1.107 + *
1.108 + * Each client is displayed as: name (userid)
1.109 + * Each item contains the userid as a string for its info.
1.110 + *
1.111 + * @param menu Menu Handle.
1.112 + * @param source_client Source client, or 0 to ignore immunity.
1.113 + * @param flags COMMAND_FILTER flags from commandfilters.inc.
1.114 + * @return Number of clients added.
1.115 + */
1.116 +native AddTargetsToMenu2(Handle:menu, source_client, flags);
1.117 +
1.118 +/**
1.119 + * Re-displays the admin menu to a client after selecting an item.
1.120 + * Auto-aborts if the Handle is invalid.
1.121 + *
1.122 + * @param topmenu TopMenu Handle.
1.123 + * @param client Client index.
1.124 + * @return True on success, false on failure.
1.125 + */
1.126 +stock bool:RedisplayAdminMenu(Handle:topmenu, client)
1.127 +{
1.128 + if (topmenu == INVALID_HANDLE)
1.129 + {
1.130 + return false;
1.131 + }
1.132 +
1.133 + return DisplayTopMenu(topmenu, client, TopMenuPosition_LastCategory);
1.134 +}
1.135 +
1.136 +/* DO NOT EDIT BELOW THIS LINE */
1.137 +
1.138 +public SharedPlugin:__pl_adminmenu =
1.139 +{
1.140 + name = "adminmenu",
1.141 + file = "adminmenu.smx",
1.142 +#if defined REQUIRE_PLUGIN
1.143 + required = 1,
1.144 +#else
1.145 + required = 0,
1.146 +#endif
1.147 +};
1.148 +
1.149 +#if !defined REQUIRE_PLUGIN
1.150 +public __pl_adminmenu_SetNTVOptional()
1.151 +{
1.152 + MarkNativeAsOptional("GetAdminTopMenu");
1.153 + MarkNativeAsOptional("AddTargetsToMenu");
1.154 + MarkNativeAsOptional("AddTargetsToMenu2");
1.155 +}
1.156 +#endif