Added amb<536> requested for using sm_kick without putting quotes around reason.

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401217
This commit is contained in:
Phong Dang 2007-07-29 19:20:42 +00:00
parent 64d7fd751a
commit c01022585b

View File

@ -12,7 +12,7 @@
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
@ -24,7 +24,7 @@
#include <sourcemod>
public Plugin:myinfo =
public Plugin:myinfo =
{
name = "Basic Commands",
author = "AlliedModders LLC",
@ -40,7 +40,7 @@ new Handle:hBanRemoved = INVALID_HANDLE;
public OnPluginStart()
{
LoadTranslations("common.phrases");
RegAdminCmd("sm_kick", Command_Kick, ADMFLAG_KICK, "sm_kick <#userid|name> [reason]");
RegAdminCmd("sm_map", Command_Map, ADMFLAG_CHANGEMAP, "sm_map <map>");
RegAdminCmd("sm_rcon", Command_Rcon, ADMFLAG_RCON, "sm_rcon <args>");
@ -52,7 +52,7 @@ public OnPluginStart()
RegAdminCmd("sm_addban", Command_AddBan, ADMFLAG_RCON, "sm_addban <time> <steamid> [reason]");
RegAdminCmd("sm_banip", Command_BanIp, ADMFLAG_RCON, "sm_banip <time> <ip> [reason]");
RegAdminCmd("sm_reloadadmins", Command_ReloadAdmins, ADMFLAG_BAN, "sm_reloadadmins");
hBanForward = CreateGlobalForward("OnClientBanned", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_String);
hAddBanForward = CreateGlobalForward("OnBanAdded", ET_Hook, Param_Cell, Param_String, Param_Cell, Param_String);
hBanRemoved = CreateGlobalForward("OnBanRemoved", ET_Hook, Param_Cell, Param_String);
@ -63,10 +63,10 @@ public Action:Command_ReloadAdmins(client, args)
/* Dump it all! */
DumpAdminCache(AdminCache_Groups, true);
DumpAdminCache(AdminCache_Overrides, true);
LogMessage("\"%L\" refreshed the admin cache.", client);
ReplyToCommand(client, "[SM] %t", "Admin cache refreshed");
return Plugin_Handled;
}
@ -77,19 +77,19 @@ public Action:Command_BanIp(client, args)
ReplyToCommand(client, "[SM] Usage: sm_banip <time> <ip> [reason]");
return Plugin_Handled;
}
decl String:arg[50], String:time[20];
GetCmdArg(1, time, sizeof(time));
GetCmdArg(2, arg, sizeof(arg));
new minutes = StringToInt(time);
decl String:reason[128];
if (args >= 3)
{
GetCmdArg(3, reason, sizeof(reason));
}
new Action:act = Plugin_Continue;
Call_StartForward(hAddBanForward);
Call_PushCell(client);
@ -97,19 +97,19 @@ public Action:Command_BanIp(client, args)
Call_PushCell(minutes);
Call_PushString(reason);
Call_Finish(act);
if (act < Plugin_Handled)
{
LogMessage("\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", client, minutes, arg, reason);
ReplyToCommand(client, "[SM] %t", "Ban added");
}
if (act < Plugin_Stop)
{
ServerCommand("banip %d %s", minutes, arg);
ServerCommand("writeip");
}
return Plugin_Handled;
}
@ -120,19 +120,19 @@ public Action:Command_AddBan(client, args)
ReplyToCommand(client, "[SM] Usage: sm_addban <time> <steamid> [reason]");
return Plugin_Handled;
}
decl String:arg[50], String:time[20];
GetCmdArg(1, time, sizeof(time));
GetCmdArg(2, arg, sizeof(arg));
new minutes = StringToInt(time);
decl String:reason[128];
if (args >= 3)
{
GetCmdArg(3, reason, sizeof(reason));
}
new Action:act = Plugin_Continue;
Call_StartForward(hAddBanForward);
Call_PushCell(client);
@ -140,19 +140,19 @@ public Action:Command_AddBan(client, args)
Call_PushCell(minutes);
Call_PushString(reason);
Call_Finish(act);
if (act < Plugin_Handled)
{
LogMessage("\"%L\" added ban (minutes \"%d\") (id \"%s\") (reason \"%s\")", client, minutes, arg, reason);
ReplyToCommand(client, "[SM] %t", "Ban added");
}
if (act < Plugin_Stop)
{
ServerCommand("banid %d %s", minutes, arg);
ServerCommand("writeid");
}
return Plugin_Handled;
}
@ -163,12 +163,12 @@ public Action:Command_Unban(client, args)
ReplyToCommand(client, "[SM] Usage: sm_unban <steamid>");
return Plugin_Handled;
}
decl String:arg[50];
new start=0;
decl String:new_arg[50];
GetCmdArgString(arg, sizeof(arg));
if (strncmp(arg, "STEAM_0:", 8) == 0)
{
start = 8;
@ -176,27 +176,27 @@ public Action:Command_Unban(client, args)
{
start = 2;
}
Format(new_arg, sizeof(new_arg), "STEAM_0:%s", arg[start]);
new Action:act = Plugin_Continue;
Call_StartForward(hBanRemoved);
Call_PushCell(client);
Call_PushString(new_arg);
Call_Finish(act);
if (act < Plugin_Handled)
{
LogMessage("\"%L\" removed ban (filter \"%s\")", client, arg[start]);
ReplyToCommand(client, "[SM] %t", "Removed bans matching", arg);
}
if (act < Plugin_Stop)
{
ServerCommand("removeid \"%s\"", arg[start]);
ServerCommand("writeid");
}
return Plugin_Handled;
}
@ -207,21 +207,21 @@ public Action:Command_Ban(client, args)
ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg, true);
if (target == -1)
{
return Plugin_Handled;
}
decl String:s_time[12];
GetCmdArg(2, s_time, sizeof(s_time));
new time = StringToInt(s_time);
decl String:reason[128];
if (args >= 3)
{
@ -229,11 +229,11 @@ public Action:Command_Ban(client, args)
} else {
reason[0] = '\0';
}
decl String:authid[64];
GetClientAuthString(target, authid, sizeof(authid));
GetClientName(target, arg, sizeof(arg));
/* Fire the ban forward */
new Action:act = Plugin_Continue;
Call_StartForward(hBanForward);
@ -242,7 +242,7 @@ public Action:Command_Ban(client, args)
Call_PushCell(time);
Call_PushString(reason);
Call_Finish(act);
if (act < Plugin_Handled)
{
if (!time)
@ -270,16 +270,16 @@ public Action:Command_Ban(client, args)
{
strcopy(reason, sizeof(reason), "Banned");
}
ServerCommand("banid %d %s", time, authid);
KickClient(target, "%s", reason);
if (time == 0)
{
ServerCommand("writeid");
}
}
return Plugin_Handled;
}
@ -306,7 +306,7 @@ FlagsToString(String:buffer[], maxlength, flags)
{
decl String:joins[FLAG_STRINGS][20];
new total;
for (new i=0; i<FLAG_STRINGS; i++)
{
if (flags & (1<<i))
@ -314,7 +314,7 @@ FlagsToString(String:buffer[], maxlength, flags)
strcopy(joins[total++], 20, g_FlagNames[i]);
}
}
ImplodeStrings(joins, total, ", ", buffer, maxlength);
}
@ -326,13 +326,13 @@ public Action:Command_Who(client, args)
decl String:t_access[16], String:t_name[16];
Format(t_access, sizeof(t_access), "%t", "Access", client);
Format(t_name, sizeof(t_name), "%t", "Name", client);
PrintToConsole(client, "%-24.23s %s", t_name, t_access);
/* List all players */
new maxClients = GetMaxClients();
decl String:flagstring[255];
for (new i=1; i<=maxClients; i++)
{
if (!IsClientInGame(i))
@ -352,21 +352,21 @@ public Action:Command_Who(client, args)
GetClientName(i, name, sizeof(name));
PrintToConsole(client, "%d. %-24.23s %s", i, name, flagstring);
}
if (GetCmdReplySource() == SM_REPLY_TO_CHAT)
{
ReplyToCommand(client, "[SM] %t", "See console for output");
}
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new clients[2];
new numClients = SearchForClients(arg, clients, 2);
if (numClients == 0)
{
ReplyToCommand(client, "[SM] %t", "No matching client");
@ -375,7 +375,7 @@ public Action:Command_Who(client, args)
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
return Plugin_Handled;
}
new flags = GetUserFlagBits(clients[0]);
decl String:flagstring[255];
if (flags == 0)
@ -386,9 +386,9 @@ public Action:Command_Who(client, args)
} else {
FlagsToString(flagstring, sizeof(flagstring), flags);
}
ReplyToCommand(client, "[SM] %t: %s", "Access", flagstring);
return Plugin_Handled;
}
@ -399,22 +399,22 @@ public Action:Command_ExecCfg(client, args)
ReplyToCommand(client, "[SM] Usage: sm_execcfg <filename>");
return Plugin_Handled;
}
new String:path[64] = "cfg/";
GetCmdArg(1, path[4], sizeof(path)-4);
if (!FileExists(path))
{
ReplyToCommand(client, "[SM] %t", "Config not found", path[4]);
return Plugin_Handled;
}
ShowActivity(client, "%t", "Executed config", path[4]);
LogMessage("\"%L\" executed config (file \"%s\")", client, path[4]);
ServerCommand("exec \"%s\"", path[4]);
return Plugin_Handled;
}
@ -425,17 +425,17 @@ public Action:Command_Cvar(client, args)
ReplyToCommand(client, "[SM] Usage: sm_cvar <cvar> [value]");
return Plugin_Handled;
}
decl String:cvarname[33];
GetCmdArg(1, cvarname, sizeof(cvarname));
new Handle:hndl = FindConVar(cvarname);
if (hndl == INVALID_HANDLE)
{
ReplyToCommand(client, "[SM] %t", "Unable to find cvar", cvarname);
return Plugin_Handled;
}
new bool:allowed = false;
if (GetConVarFlags(hndl) & FCVAR_PROTECTED)
{
@ -449,7 +449,7 @@ public Action:Command_Cvar(client, args)
{
allowed = true;
}
}
}
/* Do a check for the cheat cvar */
else if (StrEqual(cvarname, "sv_cheats"))
{
@ -464,35 +464,35 @@ public Action:Command_Cvar(client, args)
{
allowed = true;
}
if (!allowed)
{
ReplyToCommand(client, "[SM] %t", "No access to cvar");
return Plugin_Handled;
}
decl String:value[255];
if (args < 2)
{
GetConVarString(hndl, value, sizeof(value));
ReplyToCommand(client, "[SM] %t", "Value of cvar", cvarname, value);
return Plugin_Handled;
}
GetCmdArg(2, value, sizeof(value));
if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
{
ShowActivity(client, "%t", "Cvar changed", cvarname, value);
} else {
ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
}
LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
SetConVarString(hndl, value, true);
return Plugin_Handled;
}
@ -503,14 +503,14 @@ public Action:Command_Rcon(client, args)
ReplyToCommand(client, "[SM] Usage: sm_rcon <args>");
return Plugin_Handled;
}
decl String:argstring[255];
GetCmdArgString(argstring, sizeof(argstring));
LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
ServerCommand("%s", argstring);
return Plugin_Handled;
}
@ -521,36 +521,36 @@ public Action:Command_Map(client, args)
ReplyToCommand(client, "[SM] Usage: sm_map <map>");
return Plugin_Handled;
}
decl String:map[64];
GetCmdArg(1, map, sizeof(map));
if (!IsMapValid(map))
{
ReplyToCommand(client, "[SM] %t", "Map was not found", map);
return Plugin_Handled;
}
ShowActivity(client, "%t", "Changing map", map);
LogMessage("\"%L\" changed map to \"%s\"", client, map);
new Handle:dp;
CreateDataTimer(3.0, Timer_ChangeMap, dp);
WritePackString(dp, map);
return Plugin_Handled;
}
public Action:Timer_ChangeMap(Handle:timer, Handle:dp)
{
decl String:map[65];
ResetPack(dp);
ReadPackString(dp, map, sizeof(map));
ServerCommand("changelevel \"%s\"", map);
return Plugin_Stop;
}
@ -561,35 +561,37 @@ public Action:Command_Kick(client, args)
ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
return Plugin_Handled;
}
decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg));
new target = FindTarget(client, arg);
if (target == -1)
{
return Plugin_Handled;
}
decl String:name[65];
GetClientName(target, name, sizeof(name));
decl String:reason[256];
if (args < 2)
{
/* Safely null terminate */
reason[0] = '\0';
} else {
GetCmdArg(2, reason, sizeof(reason));
GetCmdArgString(reason, sizeof(reason));
new len = BreakString(reason, arg, sizeof(arg));
strcopy(reason, sizeof(reason), reason[len]);
}
ShowActivity(client, "%t", "Kicked player", name);
LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, target, reason);
KickClient(target, "%s", reason);
return Plugin_Handled;
}