plugins/basefuncommands.sp
author Scott Ehlert <ds@alliedmods.net>
Fri Aug 10 09:16:58 2007 +0000 (2007-08-10)
changeset 1301 a9e6cd2953f2
parent 1280 13c62962a9ef
child 1330 ab94316bb52b
permissions -rw-r--r--
Added replicate and notify parameters to ResetConVar() - these were already available for SetConVarX()
     1 /**
     2  * basefuncommands.sp
     3  * Implements basic punishment commands.
     4  * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
     5  *
     6  * This program is free software; you can redistribute it and/or
     7  * modify it under the terms of the GNU General Public License
     8  * as published by the Free Software Foundation; either version 2
     9  * of the License, or (at your option) any later version.
    10  *
    11  * This program is distributed in the hope that it will be useful,
    12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  * GNU General Public License for more details.
    15  *
    16  * You should have received a copy of the GNU General Public License
    17  * along with this program; if not, write to the Free Software
    18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
    19  *
    20  * Version: $Id$
    21  */
    22 
    23 #pragma semicolon 1
    24 
    25 #include <sourcemod>
    26 #include <sdktools>
    27 
    28 public Plugin:myinfo =
    29 {
    30 	name = "Basic Fun Commands",
    31 	author = "AlliedModders LLC",
    32 	description = "Basic Fun Commands",
    33 	version = SOURCEMOD_VERSION,
    34 	url = "http://www.sourcemod.net/"
    35 };
    36 
    37 public OnPluginStart()
    38 {
    39 	LoadTranslations("common.phrases");
    40 
    41 	RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
    42 	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
    43 	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
    44 	RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
    45 }
    46 
    47 public Action:Command_Play(client, args)
    48 {
    49 	if (args < 2)
    50 	{
    51 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
    52 	}
    53 
    54 	new String:Arguments[PLATFORM_MAX_PATH + 65];
    55 	GetCmdArgString(Arguments, sizeof(Arguments));
    56 
    57  	decl String:Arg[65];
    58 	new len = BreakString(Arguments, Arg, sizeof(Arg));
    59 
    60 	new target = FindTarget(client, Arg);
    61 	if (target == -1)
    62 	{
    63 		return Plugin_Handled;
    64 	}
    65 
    66 	/* Make sure it does not go out of bound by doing "sm_play user  "*/
    67 	if (len == -1)
    68 	{
    69 		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
    70 		return Plugin_Handled;
    71 	}
    72 
    73 	/* Incase they put quotes and white spaces after the quotes */
    74 	if (Arguments[len] == '"')
    75 	{
    76 		len++;
    77 		new FileLen = TrimString(Arguments[len]) + len;
    78 
    79 		if (Arguments[FileLen - 1] == '"')
    80 		{
    81 			Arguments[FileLen - 1] = '\0';
    82 		}
    83 	}
    84 
    85 	GetClientName(target, Arg, sizeof(Arg));
    86 	ShowActivity(client, "%t", "Played Sound", Arg);
    87 	LogMessage("\"%L\" played sound on \"%L\" (file \"%s\")", client, target, Arguments[len]);
    88 
    89 	ClientCommand(target, "playgamesound \"%s\"", Arguments[len]);
    90 
    91 	return Plugin_Handled;
    92 }
    93 
    94 public Action:Command_Burn(client, args)
    95 {
    96 	if (args < 1)
    97 	{
    98 		ReplyToCommand(client, "[SM] Usage: sm_burn <#userid|name> [time]");
    99 		return Plugin_Handled;
   100 	}
   101 
   102 	decl String:arg[65];
   103 	GetCmdArg(1, arg, sizeof(arg));
   104 
   105 	new target = FindTarget(client, arg);
   106 	if (target == -1)
   107 	{
   108 		return Plugin_Handled;
   109 	}
   110 
   111 	GetClientName(target, arg, sizeof(arg));
   112 	
   113 	if (!IsPlayerAlive(target))
   114 	{
   115 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   116 		return Plugin_Handled;
   117 	}
   118 	
   119 	new Float:seconds = 20.0;
   120 	if (args > 1)
   121 	{
   122 		decl String:time[20];
   123 		GetCmdArg(2, time, sizeof(time));
   124 		if (StringToFloatEx(time, seconds) == 0)
   125 		{
   126 			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   127 			return Plugin_Handled;
   128 		}
   129 	}
   130 
   131 	ShowActivity(client, "%t", "Ignited player", arg);
   132 	LogMessage("\"%L\" ignited \"%L\" (seconds \"%f\")", client, target, seconds);
   133 	IgniteEntity(target, seconds);
   134 
   135 	return Plugin_Handled;
   136 }
   137 
   138 public Action:Command_Slap(client, args)
   139 {
   140 	if (args < 1)
   141 	{
   142 		ReplyToCommand(client, "[SM] Usage: sm_slap <#userid|name> [damage]");
   143 		return Plugin_Handled;
   144 	}
   145 
   146 	decl String:arg[65];
   147 	GetCmdArg(1, arg, sizeof(arg));
   148 
   149 	new target = FindTarget(client, arg);
   150 	if (target == -1)
   151 	{
   152 		return Plugin_Handled;
   153 	}
   154 
   155 	GetClientName(target, arg, sizeof(arg));
   156 
   157 	if (!IsPlayerAlive(target))
   158 	{
   159 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   160 		return Plugin_Handled;
   161 	}	
   162 	
   163 	new damage = 5;
   164 	if (args > 1)
   165 	{
   166 		decl String:arg2[20];
   167 		GetCmdArg(2, arg2, sizeof(arg2));
   168 		if (StringToIntEx(arg2, damage) == 0)
   169 		{
   170 			ReplyToCommand(client, "[SM] %t", "Invalid Amount");
   171 			return Plugin_Handled;
   172 		}
   173 	}
   174 
   175 	ShowActivity(client, "%t", "Slapped player", arg);
   176 	LogMessage("\"%L\" slapped \"%L\" (damage \"%d\")", client, target, damage);
   177 	SlapPlayer(target, damage, true);
   178 
   179 	return Plugin_Handled;
   180 }
   181 
   182 public Action:Command_Slay(client, args)
   183 {
   184 	if (args < 1)
   185 	{
   186 		ReplyToCommand(client, "[SM] Usage: sm_slay <#userid|name>");
   187 		return Plugin_Handled;
   188 	}
   189 
   190 	decl String:arg[65];
   191 	GetCmdArg(1, arg, sizeof(arg));
   192 
   193 	new target = FindTarget(client, arg);
   194 	if (target == -1)
   195 	{
   196 		return Plugin_Handled;
   197 	}
   198 
   199 	GetClientName(target, arg, sizeof(arg));
   200 
   201 	if (!IsPlayerAlive(target))
   202 	{
   203 		ReplyToCommand(client, "[SM] %t", "Cannot performed on dead", arg);
   204 		return Plugin_Handled;
   205 	}	
   206 
   207 	ShowActivity(client, "%t", "Slayed player", arg);
   208 	LogMessage("\"%L\" slayed \"%L\"", client, target);
   209 	ForcePlayerSuicide(target);
   210 
   211 	return Plugin_Handled;
   212 }