plugins/basefuncommands.sp
author David Anderson <dvander@alliedmods.net>
Fri Oct 19 06:49:01 2007 +0000 (2007-10-19)
changeset 1609 4ffc85da5d7e
parent 1600 6dd806ad4812
child 1624 709b1f973c05
permissions -rw-r--r--
added amb1009 - fortress forever support
ferret99gt@1194
     1
/**
ds@1330
     2
 * vim: set ts=4 :
ds@1330
     3
 * =============================================================================
ds@1330
     4
 * SourceMod Basic Fun Commands Plugin
ferret99gt@1194
     5
 * Implements basic punishment commands.
ds@1330
     6
 *
ds@1330
     7
 * SourceMod (C)2004-2007 AlliedModders LLC.  All rights reserved.
ds@1330
     8
 * =============================================================================
ferret99gt@1194
     9
 *
ds@1330
    10
 * This program is free software; you can redistribute it and/or modify it under
ds@1330
    11
 * the terms of the GNU General Public License, version 3.0, as published by the
ds@1330
    12
 * Free Software Foundation.
ds@1330
    13
 * 
ds@1330
    14
 * This program is distributed in the hope that it will be useful, but WITHOUT
ds@1330
    15
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
ds@1330
    16
 * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
ds@1330
    17
 * details.
ferret99gt@1194
    18
 *
ds@1330
    19
 * You should have received a copy of the GNU General Public License along with
ds@1330
    20
 * this program.  If not, see <http://www.gnu.org/licenses/>.
teame06@1212
    21
 *
ds@1330
    22
 * As a special exception, AlliedModders LLC gives you permission to link the
ds@1330
    23
 * code of this program (as well as its derivative works) to "Half-Life 2," the
ds@1330
    24
 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
ds@1330
    25
 * by the Valve Corporation.  You must obey the GNU General Public License in
ds@1330
    26
 * all respects for all other code used.  Additionally, AlliedModders LLC grants
ds@1330
    27
 * this exception to all derivative works.  AlliedModders LLC defines further
ds@1330
    28
 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
ds@1330
    29
 * or <http://www.sourcemod.net/license.php>.
ferret99gt@1194
    30
 *
ferret99gt@1194
    31
 * Version: $Id$
ferret99gt@1194
    32
 */
ferret99gt@1194
    33
ferret99gt@1194
    34
#pragma semicolon 1
ferret99gt@1194
    35
ferret99gt@1194
    36
#include <sourcemod>
ferret99gt@1194
    37
#include <sdktools>
pred@1536
    38
#undef REQUIRE_PLUGIN
pred@1536
    39
#include <adminmenu>
ferret99gt@1194
    40
teame06@1212
    41
public Plugin:myinfo =
ferret99gt@1194
    42
{
ferret99gt@1194
    43
	name = "Basic Fun Commands",
ferret99gt@1194
    44
	author = "AlliedModders LLC",
ferret99gt@1194
    45
	description = "Basic Fun Commands",
ferret99gt@1194
    46
	version = SOURCEMOD_VERSION,
ferret99gt@1194
    47
	url = "http://www.sourcemod.net/"
ferret99gt@1194
    48
};
ferret99gt@1194
    49
pred@1536
    50
new Handle:hTopMenu = INVALID_HANDLE;
pred@1536
    51
pred@1536
    52
new g_SlapDamage[MAXPLAYERS+1];
pred@1536
    53
pred@1536
    54
#include "basefuncommands/slay.sp"
pred@1536
    55
#include "basefuncommands/burn.sp"
pred@1536
    56
#include "basefuncommands/slap.sp"
pred@1536
    57
ferret99gt@1194
    58
public OnPluginStart()
ferret99gt@1194
    59
{
ferret99gt@1194
    60
	LoadTranslations("common.phrases");
ferret99gt@1194
    61
ferret99gt@1194
    62
	RegAdminCmd("sm_burn", Command_Burn, ADMFLAG_SLAY, "sm_burn <#userid|name> [time]");
ferret99gt@1194
    63
	RegAdminCmd("sm_slap", Command_Slap, ADMFLAG_SLAY, "sm_slap <#userid|name> [damage]");
ferret99gt@1194
    64
	RegAdminCmd("sm_slay", Command_Slay, ADMFLAG_SLAY, "sm_slay <#userid|name>");
teame06@1214
    65
	RegAdminCmd("sm_play", Command_Play, ADMFLAG_GENERIC, "sm_play <#userid|name> <filename>");
pred@1536
    66
	
pred@1536
    67
	/* Account for late loading */
pred@1536
    68
	new Handle:topmenu;
pred@1536
    69
	if (LibraryExists("adminmenu") && ((topmenu = GetAdminTopMenu()) != INVALID_HANDLE))
pred@1536
    70
	{
pred@1536
    71
		OnAdminMenuReady(topmenu);
pred@1536
    72
	}
pred@1536
    73
}
pred@1536
    74
pred@1536
    75
public OnAdminMenuReady(Handle:topmenu)
pred@1536
    76
{
pred@1536
    77
	/* Block us from being called twice */
pred@1536
    78
	if (topmenu == hTopMenu)
pred@1536
    79
	{
pred@1536
    80
		return;
pred@1536
    81
	}
pred@1536
    82
	
pred@1536
    83
	/* Save the Handle */
pred@1536
    84
	hTopMenu = topmenu;
pred@1536
    85
	
pred@1536
    86
	/* Find the "Player Commands" category */
pred@1536
    87
	new TopMenuObject:player_commands = FindTopMenuCategory(hTopMenu, ADMINMENU_PLAYERCOMMANDS);
pred@1536
    88
pred@1536
    89
	if (player_commands != INVALID_TOPMENUOBJECT)
pred@1536
    90
	{
pred@1536
    91
		AddToTopMenu(hTopMenu,
dvander@1600
    92
			"sm_slay",
pred@1536
    93
			TopMenuObject_Item,
pred@1536
    94
			AdminMenu_Slay,
pred@1536
    95
			player_commands,
pred@1536
    96
			"sm_slay",
pred@1536
    97
			ADMFLAG_SLAY);
pred@1536
    98
			
pred@1536
    99
		AddToTopMenu(hTopMenu,
dvander@1600
   100
			"sm_burn",
pred@1536
   101
			TopMenuObject_Item,
pred@1536
   102
			AdminMenu_Burn,
pred@1536
   103
			player_commands,
pred@1536
   104
			"sm_burn",
pred@1536
   105
			ADMFLAG_SLAY);
pred@1536
   106
			
pred@1536
   107
		AddToTopMenu(hTopMenu,
dvander@1600
   108
			"sm_slap",
pred@1536
   109
			TopMenuObject_Item,
pred@1536
   110
			AdminMenu_Slap,
pred@1536
   111
			player_commands,
pred@1536
   112
			"sm_slap",
pred@1536
   113
			ADMFLAG_SLAY);	
pred@1536
   114
	}
teame06@1212
   115
}
teame06@1212
   116
teame06@1212
   117
public Action:Command_Play(client, args)
teame06@1212
   118
{
teame06@1241
   119
	if (args < 2)
teame06@1212
   120
	{
teame06@1214
   121
		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
teame06@1212
   122
	}
teame06@1212
   123
teame06@1214
   124
	new String:Arguments[PLATFORM_MAX_PATH + 65];
teame06@1214
   125
	GetCmdArgString(Arguments, sizeof(Arguments));
teame06@1214
   126
teame06@1214
   127
 	decl String:Arg[65];
teame06@1214
   128
	new len = BreakString(Arguments, Arg, sizeof(Arg));
teame06@1212
   129
teame06@1212
   130
	new target = FindTarget(client, Arg);
teame06@1212
   131
	if (target == -1)
teame06@1212
   132
	{
teame06@1212
   133
		return Plugin_Handled;
teame06@1212
   134
	}
teame06@1212
   135
teame06@1214
   136
	/* Make sure it does not go out of bound by doing "sm_play user  "*/
teame06@1241
   137
	if (len == -1)
teame06@1214
   138
	{
teame06@1214
   139
		ReplyToCommand(client, "[SM] Usage: sm_play <#userid|name> <filename>");
teame06@1214
   140
		return Plugin_Handled;
teame06@1214
   141
	}
teame06@1212
   142
teame06@1214
   143
	/* Incase they put quotes and white spaces after the quotes */
teame06@1241
   144
	if (Arguments[len] == '"')
teame06@1214
   145
	{
teame06@1214
   146
		len++;
teame06@1214
   147
		new FileLen = TrimString(Arguments[len]) + len;
teame06@1214
   148
teame06@1241
   149
		if (Arguments[FileLen - 1] == '"')
teame06@1214
   150
		{
teame06@1214
   151
			Arguments[FileLen - 1] = '\0';
teame06@1214
   152
		}
teame06@1214
   153
	}
teame06@1214
   154
teame06@1214
   155
	GetClientName(target, Arg, sizeof(Arg));
teame06@1212
   156
	ShowActivity(client, "%t", "Played Sound", Arg);
dvander@1378
   157
	LogAction(client, target, "\"%L\" played sound on \"%L\" (file \"%s\")", client, target, Arguments[len]);
teame06@1212
   158
teame06@1214
   159
	ClientCommand(target, "playgamesound \"%s\"", Arguments[len]);
teame06@1212
   160
teame06@1212
   161
	return Plugin_Handled;
ferret99gt@1194
   162
}
ferret99gt@1194
   163