plugins/basefuncommands.sp
author Borja Ferrer <faluco@alliedmods.net>
Fri Sep 28 20:13:42 2007 +0000 (2007-09-28)
changeset 1499 e55ac4555a2b
parent 1418 7404bb003948
child 1536 fe2146e4975d
permissions -rw-r--r--
synced linux build
     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 
    39 public Plugin:myinfo =
    40 {
    41 	name = "Basic Fun Commands",
    42 	author = "AlliedModders LLC",
    43 	description = "Basic Fun Commands",
    44 	version = SOURCEMOD_VERSION,
    45 	url = "http://www.sourcemod.net/"
    46 };
    47 
    48 public OnPluginStart()
    49 {
    50 	LoadTranslations("common.phrases");
    51 
    52 	RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
    53 	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    54 	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    55 	RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
    56 }
    57 
    58 public Action:Command_Play(client, args)
    59 {
    60 	if (args < 2)
    61 	{
    62 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
    63 	}
    64 
    65 	new String:Arguments[PLATFORM_MAX_PATH + 65];
    66 	GetCmdArgString(Arguments, sizeof(Arguments));
    67 
    68  	decl String:Arg[65];
    69 	new len = BreakString(Arguments, Arg, sizeof(Arg));
    70 
    71 	new target = FindTarget(client, Arg);
    72 	if (target == -1)
    73 	{
    74 		return Plugin_Handled;
    75 	}
    76 
    77 	/* Make sure it does not go out of bound by doing "sm_play user  "*/
    78 	if (len == -1)
    79 	{
    80 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
    81 		return Plugin_Handled;
    82 	}
    83 
    84 	/* Incase they put quotes and white spaces after the quotes */
    85 	if (Arguments[len] == '"')
    86 	{
    87 		len++;
    88 		new FileLen = TrimString(Arguments[len]) + len;
    89 
    90 		if (Arguments[FileLen - 1] == '"')
    91 		{
    92 			Arguments[FileLen - 1] = '\0';
    93 		}
    94 	}
    95 
    96 	GetClientName(target, Arg, sizeof(Arg));
    97 	ShowActivity(client, "%t", "Played Sound", Arg);
    98 	LogAction(client, target, "\"%L\" played sound on \"%L\" (file \"%s\")", client, target, Arguments[len]);
    99 
   100 	ClientCommand(target, "playgamesound \"%s\"", Arguments[len]);
   101 
   102 	return Plugin_Handled;
   103 }
   104 
   105 public Action:Command_Burn(client, args)
   106 {
   107 	if (args < 1)
   108 	{
   109 		ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
   110 		return Plugin_Handled;
   111 	}
   112 
   113 	decl String:arg[65];
   114 	GetCmdArg(1, arg, sizeof(arg));
   115 
   116 	new target = FindTarget(client, arg);
   117 	if (target == -1)
   118 	{
   119 		return Plugin_Handled;
   120 	}
   121 
   122 	GetClientName(target, arg, sizeof(arg));
   123 	
   124 	if (!IsPlayerAlive(target))
   125 	{
   126 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   127 		return Plugin_Handled;
   128 	}
   129 	
   130 	new Float:seconds = 20.0;
   131 	if (args > 1)
   132 	{
   133 		decl String:time[20];
   134 		GetCmdArg(2, time, sizeof(time));
   135 		if (StringToFloatEx(time, seconds) == 0)
   136 		{
   137 			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   138 			return Plugin_Handled;
   139 		}
   140 	}
   141 
   142 	ShowActivity(client, "%t", "Ignited player", arg);
   143 	LogAction(client, target, "\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
   144 	IgniteEntity(target, seconds);
   145 
   146 	return Plugin_Handled;
   147 }
   148 
   149 public Action:Command_Slap(client, args)
   150 {
   151 	if (args < 1)
   152 	{
   153 		ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
   154 		return Plugin_Handled;
   155 	}
   156 
   157 	decl String:arg[65];
   158 	GetCmdArg(1, arg, sizeof(arg));
   159 
   160 	new target = FindTarget(client, arg);
   161 	if (target == -1)
   162 	{
   163 		return Plugin_Handled;
   164 	}
   165 
   166 	GetClientName(target, arg, sizeof(arg));
   167 
   168 	if (!IsPlayerAlive(target))
   169 	{
   170 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   171 		return Plugin_Handled;
   172 	}	
   173 	
   174 	new damage = 0;
   175 	if (args > 1)
   176 	{
   177 		decl String:arg2[20];
   178 		GetCmdArg(2, arg2, sizeof(arg2));
   179 		if (StringToIntEx(arg2, damage) == 0)
   180 		{
   181 			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   182 			return Plugin_Handled;
   183 		}
   184 	}
   185 
   186 	ShowActivity(client, "%t", "Slapped player", arg);
   187 	LogAction(client, target, "\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
   188 	SlapPlayer(target, damage, true);
   189 
   190 	return Plugin_Handled;
   191 }
   192 
   193 public Action:Command_Slay(client, args)
   194 {
   195 	if (args < 1)
   196 	{
   197 		ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
   198 		return Plugin_Handled;
   199 	}
   200 
   201 	decl String:arg[65];
   202 	GetCmdArg(1, arg, sizeof(arg));
   203 
   204 	new target = FindTarget(client, arg);
   205 	if (target == -1)
   206 	{
   207 		return Plugin_Handled;
   208 	}
   209 
   210 	GetClientName(target, arg, sizeof(arg));
   211 
   212 	if (!IsPlayerAlive(target))
   213 	{
   214 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   215 		return Plugin_Handled;
   216 	}	
   217 
   218 	ShowActivity(client, "%t", "Slayed player", arg);
   219 	LogAction(client, target, "\"%L\" slayed \"%L\"", client, target);
   220 	ForcePlayerSuicide(target);
   221 
   222 	return Plugin_Handled;
   223 }