plugins/playercommands.sp
author David Anderson <dvander@alliedmods.net>
Thu Mar 05 02:05:56 2009 -0500 (2009-03-05)
changeset 2652 01152829b375
parent 2563 2860ef1261b2
child 2662 0de19a84d282
child 2680 4a5403e84378
permissions -rw-r--r--
Updated changelog.
     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 #include "playercommands/slay.sp"
    53 #include "playercommands/slap.sp"
    54 #include "playercommands/rename.sp"
    55 
    56 public OnPluginStart()
    57 {
    58 	LoadTranslations("common.phrases");
    59 	LoadTranslations("playercommands.phrases");
    60 
    61 	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    62 	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    63 	RegAdminCmd("sm_rename", Command_Rename, ADMFLAG_SLAY, "sm_rename <#userid|name>");
    64 	
    65 	/* Account for late loading */
    66 	new Handle:topmenu;
    67 	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
    68 	{
    69 		OnAdminMenuReady(topmenu);
    70 	}
    71 }
    72 
    73 public OnAdminMenuReady(Handle:topmenu)
    74 {
    75 	/* Block us from being called twice */
    76 	if (topmenu == hTopMenu)
    77 	{
    78 		return;
    79 	}
    80 	
    81 	/* Save the Handle */
    82 	hTopMenu = topmenu;
    83 	
    84 	/* Find the "Player Commands" category */
    85 	new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
    86 
    87 	if (player_commands != INVALID_TOPMENUOBJECT)
    88 	{
    89 		AddToTopMenu(hTopMenu,
    90 			"sm_slay",
    91 			TopMenuObject_Item,
    92 			AdminMenu_Slay,
    93 			player_commands,
    94 			"sm_slay",
    95 			ADMFLAG_SLAY);
    96 			
    97 		AddToTopMenu(hTopMenu,
    98 			"sm_slap",
    99 			TopMenuObject_Item,
   100 			AdminMenu_Slap,
   101 			player_commands,
   102 			"sm_slap",
   103 			ADMFLAG_SLAY);
   104 
   105 		AddToTopMenu(hTopMenu,
   106 			"sm_rename",
   107 			TopMenuObject_Item,
   108 			AdminMenu_Rename,
   109 			player_commands,
   110 			"sm_rename",
   111 			ADMFLAG_SLAY);
   112 	}
   113 }