plugins/basefuncommands.sp
author Michael McKoy <ferret99gt@gmail.com>
Sat Oct 13 19:41:25 2007 +0000 (2007-10-13)
changeset 1539 74121104e67d
parent 1536 fe2146e4975d
child 1591 3f28cc06e235
permissions -rw-r--r--
Fixed an incorrect variable name
     1 /**
     2  * vim: set ts=4 :
     3  * =============================================================================
     4  * SourceMod Basic Fun Commands Plugin
     5  * Implements basic punishment commands.
     6  *
     7  * SourceMod (C)2004-2007 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 = "Basic Fun Commands",
    44 	author = "AlliedModders LLC",
    45 	description = "Basic Fun Commands",
    46 	version = SOURCEMOD_VERSION,
    47 	url = "http://www.sourcemod.net/"
    48 };
    49 
    50 new Handle:hTopMenu = INVALID_HANDLE;
    51 
    52 new g_SlapDamage[MAXPLAYERS+1];
    53 
    54 #include "basefuncommands/slay.sp"
    55 #include "basefuncommands/burn.sp"
    56 #include "basefuncommands/slap.sp"
    57 
    58 public OnPluginStart()
    59 {
    60 	LoadTranslations("common.phrases");
    61 
    62 	RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
    63 	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    64 	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    65 	RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
    66 	
    67 	/* Account for late loading */
    68 	new Handle:topmenu;
    69 	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
    70 	{
    71 		OnAdminMenuReady(topmenu);
    72 	}
    73 }
    74 
    75 public OnAdminMenuReady(Handle:topmenu)
    76 {
    77 	/* Block us from being called twice */
    78 	if (topmenu == hTopMenu)
    79 	{
    80 		return;
    81 	}
    82 	
    83 	/* Save the Handle */
    84 	hTopMenu = topmenu;
    85 	
    86 	/* Find the "Player Commands" category */
    87 	new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
    88 
    89 	if (player_commands != INVALID_TOPMENUOBJECT)
    90 	{
    91 		AddToTopMenu(hTopMenu,
    92 			"Slay Player",
    93 			TopMenuObject_Item,
    94 			AdminMenu_Slay,
    95 			player_commands,
    96 			"sm_slay",
    97 			ADMFLAG_SLAY);
    98 			
    99 		AddToTopMenu(hTopMenu,
   100 			"Burn Player",
   101 			TopMenuObject_Item,
   102 			AdminMenu_Burn,
   103 			player_commands,
   104 			"sm_burn",
   105 			ADMFLAG_SLAY);
   106 			
   107 		AddToTopMenu(hTopMenu,
   108 			"Slap Player",
   109 			TopMenuObject_Item,
   110 			AdminMenu_Slap,
   111 			player_commands,
   112 			"sm_slap",
   113 			ADMFLAG_SLAY);	
   114 	}
   115 }
   116 
   117 public Action:Command_Play(client, args)
   118 {
   119 	if (args < 2)
   120 	{
   121 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
   122 	}
   123 
   124 	new String:Arguments[PLATFORM_MAX_PATH + 65];
   125 	GetCmdArgString(Arguments, sizeof(Arguments));
   126 
   127  	decl String:Arg[65];
   128 	new len = BreakString(Arguments, Arg, sizeof(Arg));
   129 
   130 	new target = FindTarget(client, Arg);
   131 	if (target == -1)
   132 	{
   133 		return Plugin_Handled;
   134 	}
   135 
   136 	/* Make sure it does not go out of bound by doing "sm_play user  "*/
   137 	if (len == -1)
   138 	{
   139 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
   140 		return Plugin_Handled;
   141 	}
   142 
   143 	/* Incase they put quotes and white spaces after the quotes */
   144 	if (Arguments[len] == '"')
   145 	{
   146 		len++;
   147 		new FileLen = TrimString(Arguments[len]) + len;
   148 
   149 		if (Arguments[FileLen - 1] == '"')
   150 		{
   151 			Arguments[FileLen - 1] = '\0';
   152 		}
   153 	}
   154 
   155 	GetClientName(target, Arg, sizeof(Arg));
   156 	ShowActivity(client, "%t", "Played Sound", Arg);
   157 	LogAction(client, target, "\"%L\" played sound on \"%L\" (file \"%s\")", client, target, Arguments[len]);
   158 
   159 	ClientCommand(target, "playgamesound \"%s\"", Arguments[len]);
   160 
   161 	return Plugin_Handled;
   162 }
   163