plugins/include/adminmenu.inc
author Nicholas Hastings <skamonkey@gmail.com>
Tue Nov 30 13:09:30 2010 -0500 (2010-11-30)
changeset 3162 d8f90b56529f
parent 2904 dc73a5a01ff5
permissions -rw-r--r--
Fixed BanClient always banning by IP address (bug 4626, r=fyren).
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     5  * =============================================================================
     6  *
     7  * This file is part of the SourceMod/SourcePawn SDK.
     8  *
     9  * This program is free software; you can redistribute it and/or modify it under
    10  * the terms of the GNU General Public License, version 3.0, as published by the
    11  * Free Software Foundation.
    12  * 
    13  * This program is distributed in the hope that it will be useful, but WITHOUT
    14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    15  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    16  * details.
    17  *
    18  * You should have received a copy of the GNU General Public License along with
    19  * this program.  If not, see <http://www.gnu.org/licenses/>.
    20  *
    21  * As a special exception, AlliedModders LLC gives you permission to link the
    22  * code of this program (as well as its derivative works) to "Half-Life 2," the
    23  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    24  * by the Valve Corporation.  You must obey the GNU General Public License in
    25  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    26  * this exception to all derivative works.  AlliedModders LLC defines further
    27  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    28  * or <http://www.sourcemod.net/license.php>.
    29  *
    30  * Version: $Id$
    31  */
    32  
    33 #if defined _adminmenu_included
    34  #endinput
    35 #endif
    36 #define _adminmenu_included
    37 
    38 /* Decide whether topmenus should be required */
    39 #if !defined REQUIRE_PLUGIN
    40  #if defined REQUIRE_EXTENSIONS
    41   #define TEMP_REQUIRE_EXTENSIONS
    42   #undef REQUIRE_EXTENSIONS
    43  #endif
    44 #endif
    45 
    46 #include <topmenus>
    47 
    48 /* Restore old REQUIRE_EXTENSIONS value if necessary */
    49 #if defined TEMP_REQUIRE_EXTENSIONS
    50  #define REQUIRE_EXTENSIONS
    51  #undef TEMP_REQUIRE_EXTENSIONS
    52 #endif
    53 
    54 /** Category for player commands. */
    55 #define ADMINMENU_PLAYERCOMMANDS		"PlayerCommands"
    56 /** Category for server commands. */
    57 #define ADMINMENU_SERVERCOMMANDS		"ServerCommands"
    58 /** Category for voting commands. */
    59 #define ADMINMENU_VOTINGCOMMANDS		"VotingCommands"
    60 
    61 /**
    62  * Called when the admin menu is created and 3rd party plugins can grab 
    63  * the Handle or add categories.
    64  * 
    65  * @param topmenu		Handle to the admin menu's TopMenu.
    66  * @noreturn
    67  */
    68 forward OnAdminMenuCreated(Handle:topmenu);
    69 
    70 /**
    71  * Called when the admin menu is ready to have items added.
    72  * 
    73  * @param topmenu		Handle to the admin menu's TopMenu.
    74  * @noreturn
    75  */
    76 forward OnAdminMenuReady(Handle:topmenu);
    77 
    78 /**
    79  * Retrieves the Handle to the admin top menu.
    80  *
    81  * @return				Handle to the admin menu's TopMenu,
    82  *						or INVALID_HANDLE if not created yet.
    83  */
    84 native Handle:GetAdminTopMenu();
    85 
    86 /**
    87  * Adds targets to an admin menu.
    88  *
    89  * Each client is displayed as: name (userid)
    90  * Each item contains the userid as a string for its info.
    91  *
    92  * @param menu			Menu Handle.
    93  * @param source_client	Source client, or 0 to ignore immunity.
    94  * @param in_game_only	True to only select in-game players.
    95  * @param alive_only 	True to only select alive players.
    96  * @return				Number of clients added.
    97  */
    98 native AddTargetsToMenu(Handle:menu, 
    99 						source_client, 
   100 						bool:in_game_only=true, 
   101 						bool:alive_only=false);
   102 
   103 /**
   104  * Adds targets to an admin menu.
   105  *
   106  * Each client is displayed as: name (userid)
   107  * Each item contains the userid as a string for its info.
   108  *
   109  * @param menu			Menu Handle.
   110  * @param source_client	Source client, or 0 to ignore immunity.
   111  * @param flags			COMMAND_FILTER flags from commandfilters.inc.
   112  * @return				Number of clients added.
   113  */
   114 native AddTargetsToMenu2(Handle:menu, source_client, flags);
   115 
   116 /**
   117  * Re-displays the admin menu to a client after selecting an item.
   118  * Auto-aborts if the Handle is invalid.
   119  *
   120  * @param topmenu		TopMenu Handle.
   121  * @param client		Client index.
   122  * @return				True on success, false on failure.
   123  */
   124 stock bool:RedisplayAdminMenu(Handle:topmenu, client)
   125 {
   126 	if (topmenu == INVALID_HANDLE)
   127 	{
   128 		return false;
   129 	}
   130 
   131 	return DisplayTopMenu(topmenu, client, TopMenuPosition_LastCategory);
   132 }
   133 
   134 /* DO NOT EDIT BELOW THIS LINE */
   135 
   136 public SharedPlugin:__pl_adminmenu = 
   137 {
   138 	name = "adminmenu",
   139 	file = "adminmenu.smx",
   140 #if defined REQUIRE_PLUGIN
   141 	required = 1,
   142 #else
   143 	required = 0,
   144 #endif
   145 };
   146 
   147 #if !defined REQUIRE_PLUGIN
   148 public __pl_adminmenu_SetNTVOptional()
   149 {
   150 	MarkNativeAsOptional("GetAdminTopMenu");
   151 	MarkNativeAsOptional("AddTargetsToMenu");
   152 	MarkNativeAsOptional("AddTargetsToMenu2");
   153 }
   154 #endif