3 * Implements basic admin commands.
4 * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
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.
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.
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.
27 public Plugin:myinfo =
29 name = "Basic Commands",
30 author = "AlliedModders LLC",
31 description = "Basic Admin Commands",
32 version = SOURCEMOD_VERSION,
33 url = "http://www.sourcemod.net/"
36 public OnPluginStart()
38 LoadTranslations("common.cfg");
39 RegAdminCmd("sm_kick", Command_Kick, ADMFLAG_KICK, "sm_kick <#userid|name> [reason]");
40 RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map>");
41 RegAdminCmd("sm_rcon", Command_Rcon, ADMFLAG_RCON, "sm_rcon <args>");
44 public Action:Command_Rcon(client, args)
48 ReplyToCommand(client, "[SM] Usage: sm_rcon <args>");
49 return Plugin_Handled;
52 decl String:argstring[255];
53 GetCmdArgString(argstring, sizeof(argstring));
55 LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
56 ServerCommand("%s", argstring);
58 return Plugin_Handled;
61 public Action:Command_Map(client, args)
65 ReplyToCommand(client, "[SM] Usage: sm_map <map>");
66 return Plugin_Handled;
70 GetCmdArg(1, map, sizeof(map));
74 ReplyToCommand(client, "[SM] %t", "Map was not found", map);
75 return Plugin_Handled;
78 LogMessage("\"%L\" changed map to \"%s\"", client, map);
79 ShowActivity(client, "%t", "Changing map", map);
80 ReplyToCommand(client, "%t", "Changing map", map);
83 CreateDataTimer(3.0, Timer_ChangeMap, dp);
84 WritePackString(dp, map);
86 return Plugin_Handled;
89 public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
94 ReadPackString(dp, map, sizeof(map));
96 ServerCommand("changelevel \"%s\"", map);
101 public Action:Command_Kick(client, args)
105 ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
106 return Plugin_Handled;
110 GetCmdArg(1, arg, sizeof(arg));
113 new numClients = SearchForClients(arg, clients, 2);
117 ReplyToCommand(client, "[SM] %t", "No matching client");
118 return Plugin_Handled;
119 } else if (numClients > 1) {
120 ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
121 return Plugin_Handled;
124 new userid = GetClientUserId(clients[0]);
127 GetClientName(clients[0], name, sizeof(name));
129 decl String:reason[256];
132 /* Safely null terminate */
135 GetCmdArg(2, reason, sizeof(reason));
138 LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
139 ShowActivity(client, "%t", "Kicked player", name);
143 ServerCommand("kickid %d", userid);
145 ServerCommand("kickid %d \"%s\"", userid, reason);
148 ReplyToCommand(client, "[SM] %t", "Client kicked", name);
150 return Plugin_Handled;