fixed amb1121 - ban commands didn't tokenize reasons properly

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%401678
This commit is contained in:
David Anderson 2007-11-11 06:41:46 +00:00
parent bb82eb772b
commit 0aa30ccde2
2 changed files with 42 additions and 29 deletions

View File

@ -106,9 +106,22 @@ public Action:Command_BanIp(client, args)
return Plugin_Handled; return Plugin_Handled;
} }
decl len, next_len;
decl String:Arguments[256];
decl String:arg[50], String:time[20]; decl String:arg[50], String:time[20];
GetCmdArg(1, time, sizeof(time));
GetCmdArg(2, arg, sizeof(arg)); GetCmdArgString(Arguments, sizeof(Arguments));
len = BreakString(Arguments, arg, sizeof(arg));
if ((next_len = BreakString(Arguments[len], time, sizeof(time))) != -1)
{
len += next_len;
}
else
{
len = 0;
Arguments[0] = '\0';
}
if (StrEqual(arg, "0")) if (StrEqual(arg, "0"))
{ {
@ -162,32 +175,26 @@ public Action:Command_BanIp(client, args)
new minutes = StringToInt(time); new minutes = StringToInt(time);
new String:reason[128];
if (args >= 3)
{
GetCmdArg(3, reason, sizeof(reason));
}
LogAction(client, LogAction(client,
hit_client, hit_client,
"\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", "\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")",
client, client,
minutes, minutes,
arg, arg,
reason); Arguments[len]);
ReplyToCommand(client, "[SM] %t", "Ban added"); ReplyToCommand(client, "[SM] %t", "Ban added");
BanIdentity(arg, BanIdentity(arg,
minutes, minutes,
BANFLAG_IP, BANFLAG_IP,
reason, Arguments[len],
"sm_banip", "sm_banip",
client); client);
if (hit_client != -1) if (hit_client != -1)
{ {
KickClient(hit_client, "Banned: %s", reason); KickClient(hit_client, "Banned: %s", Arguments[len]);
} }
return Plugin_Handled; return Plugin_Handled;

View File

@ -1,4 +1,4 @@
PrepareBan(client, target, time, String:reason[], size) PrepareBan(client, target, time, const String:reason[])
{ {
decl String:authid[64], String:name[32]; decl String:authid[64], String:name[32];
GetClientAuthString(target, authid, sizeof(authid)); GetClientAuthString(target, authid, sizeof(authid));
@ -25,11 +25,13 @@ PrepareBan(client, target, time, String:reason[], size)
if (reason[0] == '\0') if (reason[0] == '\0')
{ {
strcopy(reason, size, "Banned"); BanClient(target, time, BANFLAG_AUTO, "Banned", "Banned", "sm_ban", client);
} }
else
{
BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client); BanClient(target, time, BANFLAG_AUTO, reason, reason, "sm_ban", client);
} }
}
DisplayBanTargetMenu(client) DisplayBanTargetMenu(client)
{ {
@ -129,7 +131,7 @@ public MenuHandler_BanReasonList(Handle:menu, MenuAction:action, param1, param2)
GetMenuItem(menu, param2, info, sizeof(info)); GetMenuItem(menu, param2, info, sizeof(info));
PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info, sizeof(info)); PrepareBan(param1, g_BanTarget[param1], g_BanTime[param1], info);
} }
} }
@ -203,8 +205,12 @@ public Action:Command_Ban(client, args)
return Plugin_Handled; return Plugin_Handled;
} }
decl len, next_len;
decl String:Arguments[256];
GetCmdArgString(Arguments, sizeof(Arguments));
decl String:arg[65]; decl String:arg[65];
GetCmdArg(1, arg, sizeof(arg)); len = BreakString(Arguments, arg, sizeof(arg));
new target = FindTarget(client, arg, true); new target = FindTarget(client, arg, true);
if (target == -1) if (target == -1)
@ -213,19 +219,19 @@ public Action:Command_Ban(client, args)
} }
decl String:s_time[12]; decl String:s_time[12];
GetCmdArg(2, s_time, sizeof(s_time)); if ((next_len = BreakString(Arguments[len], s_time, sizeof(s_time))) != -1)
{
len += next_len;
}
else
{
len = 0;
Arguments[0] = '\0';
}
new time = StringToInt(s_time); new time = StringToInt(s_time);
decl String:reason[128]; PrepareBan(client, target, time, Arguments[len]);
if (args >= 3)
{
GetCmdArg(3, reason, sizeof(reason));
} else {
reason[0] = '\0';
}
PrepareBan(client, target, time, reason, sizeof(reason));
return Plugin_Handled; return Plugin_Handled;
} }