- added amb379

- fixed a format bug in basecommands.sp
- added an any tag to Call_Finish()

--HG--
extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40988
This commit is contained in:
David Anderson 2007-06-18 17:20:12 +00:00
parent 5dbcd90895
commit 7c63139574
3 changed files with 86 additions and 53 deletions

View File

@ -52,9 +52,9 @@ public OnPluginStart()
RegAdminCmd("sm_addban", Command_AddBan, ADMFLAG_RCON, "sm_addban <time> <steamid> [reason]"); 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_banip", Command_BanIp, ADMFLAG_RCON, "sm_banip <time> <ip> [reason]");
hBanForward = CreateGlobalForward("OnClientBanned", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_String); hBanForward = CreateGlobalForward("OnClientBanned", ET_Hook, Param_Cell, Param_Cell, Param_Cell, Param_String);
hAddBanForward = CreateGlobalForward("OnBanAdded", ET_Ignore, Param_Cell, Param_String, Param_Cell, Param_String); hAddBanForward = CreateGlobalForward("OnBanAdded", ET_Hook, Param_Cell, Param_String, Param_Cell, Param_String);
hBanRemoved = CreateGlobalForward("OnBanRemoved", ET_Ignore, Param_Cell, Param_String); hBanRemoved = CreateGlobalForward("OnBanRemoved", ET_Hook, Param_Cell, Param_String);
} }
public Action:Command_BanIp(client, args) public Action:Command_BanIp(client, args)
@ -77,18 +77,25 @@ public Action:Command_BanIp(client, args)
GetCmdArg(3, reason, sizeof(reason)); GetCmdArg(3, reason, sizeof(reason));
} }
LogMessage("\"%L\" added ban (minutes \"%d\") (ip \"%s\") (reason \"%s\")", client, minutes, arg, reason); new Action:act = Plugin_Continue;
Call_StartForward(hAddBanForward); Call_StartForward(hAddBanForward);
Call_PushCell(client); Call_PushCell(client);
Call_PushString(arg); Call_PushString(arg);
Call_PushCell(minutes); Call_PushCell(minutes);
Call_PushString(reason); Call_PushString(reason);
Call_Finish(); Call_Finish(act);
ServerCommand("banip %d %s", minutes, arg); if (act < Plugin_Handled)
ServerCommand("writeip"); {
ReplyToCommand(client, "[SM] %t", "Ban added"); 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; return Plugin_Handled;
} }
@ -113,18 +120,25 @@ public Action:Command_AddBan(client, args)
GetCmdArg(3, reason, sizeof(reason)); GetCmdArg(3, reason, sizeof(reason));
} }
LogMessage("\"%L\" added ban (minutes \"%d\") (id \"%s\") (reason \"%s\")", client, minutes, arg, reason); new Action:act = Plugin_Continue;
Call_StartForward(hAddBanForward); Call_StartForward(hAddBanForward);
Call_PushCell(client); Call_PushCell(client);
Call_PushString(arg); Call_PushString(arg);
Call_PushCell(minutes); Call_PushCell(minutes);
Call_PushString(reason); Call_PushString(reason);
Call_Finish(); Call_Finish(act);
ServerCommand("banid %d %s", minutes, arg); if (act < Plugin_Handled)
ServerCommand("writeid"); {
ReplyToCommand(client, "[SM] %t", "Ban added"); 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; return Plugin_Handled;
} }
@ -149,17 +163,25 @@ public Action:Command_Unban(client, args)
start = 2; start = 2;
} }
LogMessage("\"%L\" removed ban (filter \"%s\")", arg[start]);
Format(new_arg, sizeof(new_arg), "STEAM_0:%s", arg[start]); Format(new_arg, sizeof(new_arg), "STEAM_0:%s", arg[start]);
new Action:act = Plugin_Continue;
Call_StartForward(hBanRemoved); Call_StartForward(hBanRemoved);
Call_PushCell(client); Call_PushCell(client);
Call_PushString(new_arg); Call_PushString(new_arg);
Call_Finish(); Call_Finish();
ServerCommand("removeid \"%s\"", arg[start]); if (act < Plugin_Handled)
ServerCommand("writeid"); {
ReplyToCommand(client, "[SM] %t", "Removed bans matching", arg); 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; return Plugin_Handled;
} }
@ -209,44 +231,50 @@ public Action:Command_Ban(client, args)
new userid = GetClientUserId(clients[0]); new userid = GetClientUserId(clients[0]);
GetClientName(clients[0], arg, sizeof(arg)); GetClientName(clients[0], arg, sizeof(arg));
if (!time)
{
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Permabanned player", arg);
} else {
ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
}
} else {
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Banned player", arg, time);
} else {
ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
}
}
LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, clients[0], time, reason);
/* Fire the ban forward */ /* Fire the ban forward */
new Action:act = Plugin_Continue;
Call_StartForward(hBanForward); Call_StartForward(hBanForward);
Call_PushCell(client); Call_PushCell(client);
Call_PushCell(clients[0]); Call_PushCell(clients[0]);
Call_PushCell(time); Call_PushCell(time);
Call_PushString(reason); Call_PushString(reason);
Call_Finish(); Call_Finish();
if (reason[0] == '\0') if (act < Plugin_Handled)
{ {
strcopy(reason, sizeof(reason), "Banned"); if (!time)
{
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Permabanned player", arg);
} else {
ShowActivity(client, "%t", "Permabanned player reason", arg, reason);
}
} else {
if (reason[0] == '\0')
{
ShowActivity(client, "%t", "Banned player", arg, time);
} else {
ShowActivity(client, "%t", "Banned player reason", arg, time, reason);
}
}
LogMessage("\"%L\" banned \"%L\" (minutes \"%d\") (reason \"%s\")", client, clients[0], time, reason);
} }
ServerCommand("banid %d %d", time, userid); if (act < Plugin_Stop)
ServerCommand("kickid %d \"%s\"", userid, reason);
if (time == 0)
{ {
ServerCommand("writeid"); if (reason[0] == '\0')
{
strcopy(reason, sizeof(reason), "Banned");
}
ServerCommand("banid %d %d", time, userid);
ServerCommand("kickid %d \"%s\"", userid, reason);
if (time == 0)
{
ServerCommand("writeid");
}
} }
return Plugin_Handled; return Plugin_Handled;

View File

@ -310,7 +310,7 @@ native Call_PushStringEx(String:value[], length, szflags, cpflags);
* @return SP_ERROR_NONE on success, any other integer on failure. * @return SP_ERROR_NONE on success, any other integer on failure.
* @error Called before a call has been started. * @error Called before a call has been started.
*/ */
native Call_Finish(&result=0); native Call_Finish(&any:result=0);
/** /**
* Cancels a call to a function or forward's call list. * Cancels a call to a function or forward's call list.

View File

@ -25,8 +25,9 @@
* @param client Client index which will be banned. * @param client Client index which will be banned.
* @param time Minutes banned for (0 is permanent). * @param time Minutes banned for (0 is permanent).
* @param reason Ban reason (may be empty if none exists). * @param reason Ban reason (may be empty if none exists).
* @return Pl_Handled to block output, Pl_Stop to block output and action.
*/ */
forward OnClientBanned(admin, client, time, const String:reason[]); forward Action:OnClientBanned(admin, client, time, const String:reason[]);
/** /**
* Provided by basecommands.sp when sm_addban or sm_banip is called. * Provided by basecommands.sp when sm_addban or sm_banip is called.
@ -35,19 +36,22 @@ forward OnClientBanned(admin, client, time, const String:reason[]);
* @param info User info (either steamid or ip). * @param info User info (either steamid or ip).
* @param time Minutes banned for (0 is permanent). * @param time Minutes banned for (0 is permanent).
* @param reason Ban reason (may be empty if none exists). * @param reason Ban reason (may be empty if none exists).
* @return Pl_Handled to block output, Pl_Stop to block output and action.
*/ */
forward OnBanAdded(admin, const String:info[], time, const String:reason[]); forward Action:OnBanAdded(admin, const String:info[], time, const String:reason[]);
/** /**
* Provided by basecommands.sp when sm_unban or sm_unbanip is called. * Provided by basecommands.sp when sm_unban or sm_unbanip is called.
* *
* @param admin Admin client index (0 for server). * @param admin Admin client index (0 for server).
* @param info User info (either steamid or ip). * @param info User info (either steamid or ip).
* @return Pl_Handled to block output, Pl_Stop to block output and action.
*/ */
forward OnBanRemoved(admin, const String:info[]); forward Action:OnBanRemoved(admin, const String:info[]);
/** /**
* Formats a user's info as log text. * Formats a user's info as log text. This is usually not needed because
* %L can be used to auto-format client information into a string.
* *
* @param client Client index. * @param client Client index.
* @param buffer Buffer for text. * @param buffer Buffer for text.
@ -93,6 +97,7 @@ stock Handle:FindPluginByFile(const String:filename[])
GetPluginFilename(pl, buffer, sizeof(buffer)); GetPluginFilename(pl, buffer, sizeof(buffer));
if (StrCompare(buffer, filename) == 0) if (StrCompare(buffer, filename) == 0)
{ {
CloseHandle(iter);
return pl; return pl;
} }
} }