plugins/playercommands.sp
author Erik Minekus <erik@interwavestudios.com>
Wed Jun 23 23:41:47 2010 -0400 (2010-06-23)
changeset 3052 a102c645bf4b
parent 2688 773419643862
child 3961 0dc477c29792
permissions -rw-r--r--
Fixed lack of error checking on sm_motd. (bug 4460, r=dvander)
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Player Commands Plugin
     5  * Implements slap and slay commands
     6  *
     7  * SourceMod (C)2004-2008 AlliedModders LLC.  All rights reserved.
     8  * =============================================================================
     9  *
    10  * This program is free software; you can redistribute it and/or modify it under
    11  * the terms of the GNU General Public License, version 3.0, as published by the
    12  * Free Software Foundation.
    13  * 
    14  * This program is distributed in the hope that it will be useful, but WITHOUT
    15  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
    16  * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
    17  * details.
    18  *
    19  * You should have received a copy of the GNU General Public License along with
    20  * this program.  If not, see <http://www.gnu.org/licenses/>.
    21  *
    22  * As a special exception, AlliedModders LLC gives you permission to link the
    23  * code of this program (as well as its derivative works) to "Half-Life 2," the
    24  * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
    25  * by the Valve Corporation.  You must obey the GNU General Public License in
    26  * all respects for all other code used.  Additionally, AlliedModders LLC grants
    27  * this exception to all derivative works.  AlliedModders LLC defines further
    28  * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
    29  * or <http://www.sourcemod.net/license.php>.
    30  *
    31  * Version: $Id$
    32  */
    33 
    34 #pragma semicolon 1
    35 
    36 #include <sourcemod>
    37 #include <sdktools>
    38 #undef REQUIRE_PLUGIN
    39 #include <adminmenu>
    40 
    41 public Plugin:myinfo =
    42 {
    43 	name = "Player Commands",
    44 	author = "AlliedModders LLC",
    45 	description = "Misc. Player Commands",
    46 	version = SOURCEMOD_VERSION,
    47 	url = "http://www.sourcemod.net/"
    48 };
    49 
    50 new Handle:hTopMenu = INVALID_HANDLE;
    51 
    52 /* Used to get the SDK / Engine version. */
    53 /* This is used in sm_rename and sm_changeteam */
    54 new g_ModVersion = 0;
    55 
    56 #include "playercommands/slay.sp"
    57 #include "playercommands/slap.sp"
    58 #include "playercommands/rename.sp"
    59 
    60 public OnPluginStart()
    61 {
    62 	LoadTranslations("common.phrases");
    63 	LoadTranslations("playercommands.phrases");
    64 
    65 	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    66 	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    67 	RegAdminCmd("sm_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>");
    68 
    69 	g_ModVersion = GuessSDKVersion();
    70 	
    71 	/* Account for late loading */
    72 	new Handle:topmenu;
    73 	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
    74 	{
    75 		OnAdminMenuReady(topmenu);
    76 	}
    77 }
    78 
    79 public OnAdminMenuReady(Handle:topmenu)
    80 {
    81 	/* Block us from being called twice */
    82 	if (topmenu == hTopMenu)
    83 	{
    84 		return;
    85 	}
    86 	
    87 	/* Save the Handle */
    88 	hTopMenu = topmenu;
    89 	
    90 	/* Find the "Player Commands" category */
    91 	new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
    92 
    93 	if (player_commands != INVALID_TOPMENUOBJECT)
    94 	{
    95 		AddToTopMenu(hTopMenu,
    96 			"sm_slay",
    97 			TopMenuObject_Item,
    98 			AdminMenu_Slay,
    99 			player_commands,
   100 			"sm_slay",
   101 			ADMFLAG_SLAY);
   102 			
   103 		AddToTopMenu(hTopMenu,
   104 			"sm_slap",
   105 			TopMenuObject_Item,
   106 			AdminMenu_Slap,
   107 			player_commands,
   108 			"sm_slap",
   109 			ADMFLAG_SLAY);
   110 
   111 		AddToTopMenu(hTopMenu,
   112 			"sm_rename",
   113 			TopMenuObject_Item,
   114 			AdminMenu_Rename,
   115 			player_commands,
   116 			"sm_rename",
   117 			ADMFLAG_SLAY);
   118 	}
   119 }