- ShowActivity() now handles command usage confirmation
- added sm_ban - fixed up various issues and bugs in basecommands.sp --HG-- extra : convert_revision : svn%3A39bc706e-5318-0410-9160-8a85361fbb7c/trunk%40930
This commit is contained in:
parent
a5d17bbf6b
commit
0ceec15c5a
@ -18,6 +18,7 @@
|
|||||||
#include "HalfLife2.h"
|
#include "HalfLife2.h"
|
||||||
#include "sourcemod.h"
|
#include "sourcemod.h"
|
||||||
#include <inetchannelinfo.h>
|
#include <inetchannelinfo.h>
|
||||||
|
#include "ChatTriggers.h"
|
||||||
|
|
||||||
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
|
ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
|
||||||
|
|
||||||
@ -822,17 +823,15 @@ static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
|
|||||||
|
|
||||||
static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
|
static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
|
||||||
{
|
{
|
||||||
|
char message[255];
|
||||||
|
char buffer[255];
|
||||||
int value = sm_show_activity.GetInt();
|
int value = sm_show_activity.GetInt();
|
||||||
|
unsigned int replyto = g_ChatTriggers.GetReplyTo();
|
||||||
if (!value)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int client = params[1];
|
int client = params[1];
|
||||||
|
|
||||||
const char *name = "Console";
|
const char *name = "Console";
|
||||||
const char *sign = "ADMIN";
|
const char *sign = "ADMIN";
|
||||||
|
bool display_in_chat = false;
|
||||||
if (client != 0)
|
if (client != 0)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
|
||||||
@ -847,15 +846,35 @@ static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
|
|||||||
{
|
{
|
||||||
sign = "PLAYER";
|
sign = "PLAYER";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Display the message to the client? */
|
||||||
|
if (replyto == SM_REPLY_CONSOLE)
|
||||||
|
{
|
||||||
|
g_SourceMod.SetGlobalTarget(client);
|
||||||
|
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
|
||||||
|
UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
|
||||||
|
engine->ClientPrintf(pPlayer->GetEdict(), message);
|
||||||
|
display_in_chat = true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
g_SourceMod.SetGlobalTarget(LANG_SERVER);
|
||||||
|
g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
|
||||||
|
UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
|
||||||
|
META_CONPRINT(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!value)
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
char message[255];
|
|
||||||
char buffer[255];
|
|
||||||
int maxClients = g_Players.GetMaxClients();
|
int maxClients = g_Players.GetMaxClients();
|
||||||
for (int i=1; i<=maxClients; i++)
|
for (int i=1; i<=maxClients; i++)
|
||||||
{
|
{
|
||||||
CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
|
CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
|
||||||
if (!pPlayer->IsInGame() || pPlayer->IsFakeClient())
|
if (!pPlayer->IsInGame()
|
||||||
|
|| pPlayer->IsFakeClient()
|
||||||
|
|| (display_in_chat && i == client))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -43,6 +43,87 @@ public OnPluginStart()
|
|||||||
RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
|
RegAdminCmd("sm_cvar", Command_Cvar, ADMFLAG_CONVARS, "sm_cvar <cvar> [value]");
|
||||||
RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
|
RegAdminCmd("sm_execcfg", Command_ExecCfg, ADMFLAG_CONFIG, "sm_execcfg <filename>");
|
||||||
RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
|
RegAdminCmd("sm_who", Command_Who, ADMFLAG_GENERIC, "sm_who [#userid|name]");
|
||||||
|
RegAdminCmd("sm_ban", Command_Ban, ADMFLAG_BAN, "sm_ban <#userid|name> <minutes|0> [reason]");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Action:Command_Ban(client, args)
|
||||||
|
{
|
||||||
|
if (args < 2)
|
||||||
|
{
|
||||||
|
ReplyToCommand(client, "[SM] Usage: sm_ban <#userid|name> <minutes|0> [reason]");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
new 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");
|
||||||
|
return Plugin_Handled;
|
||||||
|
} else if (numClients > 1) {
|
||||||
|
ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
|
||||||
|
return Plugin_Handled;
|
||||||
|
} else if (!CanUserTarget(client, clients[0])) {
|
||||||
|
ReplyToCommand(client, "[SM] %t", "Unable to target");
|
||||||
|
return Plugin_Handled;
|
||||||
|
} else if (IsFakeClient(clients[0])) {
|
||||||
|
ReplyToCommand(client, "[SM] %t", "Cannot target bot");
|
||||||
|
return Plugin_Handled;
|
||||||
|
}
|
||||||
|
|
||||||
|
new String:s_time[12];
|
||||||
|
GetCmdArg(2, s_time, sizeof(s_time));
|
||||||
|
|
||||||
|
new time = StringToInt(s_time);
|
||||||
|
|
||||||
|
decl String:reason[128];
|
||||||
|
if (args >= 3)
|
||||||
|
{
|
||||||
|
GetCmdArg(3, reason, sizeof(reason));
|
||||||
|
} else {
|
||||||
|
reason[0] = '\0';
|
||||||
|
}
|
||||||
|
|
||||||
|
new userid = GetClientUserId(clients[0]);
|
||||||
|
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);
|
||||||
|
|
||||||
|
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;
|
||||||
}
|
}
|
||||||
|
|
||||||
#define FLAG_STRINGS 14
|
#define FLAG_STRINGS 14
|
||||||
@ -171,12 +252,11 @@ public Action:Command_ExecCfg(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("\"%L\" executed config (file \"%s\")", client, path[4]);
|
|
||||||
ShowActivity(client, "%t", "Executed config", path[4]);
|
ShowActivity(client, "%t", "Executed config", path[4]);
|
||||||
|
|
||||||
ServerCommand("exec \"%s\"", path[4]);
|
LogMessage("\"%L\" executed config (file \"%s\")", client, path[4]);
|
||||||
|
|
||||||
ReplyToCommand(client, "[SM] %t", "Executed config", path[4]);
|
ServerCommand("exec \"%s\"", path[4]);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
@ -244,14 +324,16 @@ public Action:Command_Cvar(client, args)
|
|||||||
|
|
||||||
GetCmdArg(2, value, sizeof(value));
|
GetCmdArg(2, value, sizeof(value));
|
||||||
|
|
||||||
LogMessage("\"%L\" changed cvar (cvar \"%s\") (value \"%s\")", client, cvarname, value);
|
|
||||||
if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
|
if ((GetConVarFlags(hndl) & FCVAR_PROTECTED) != FCVAR_PROTECTED)
|
||||||
{
|
{
|
||||||
ShowActivity(client, "%t", "Cvar changed", cvarname, value);
|
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);
|
SetConVarString(hndl, value);
|
||||||
ReplyToCommand(client, "[SM] %t", "Cvar changed", cvarname, value);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
@ -268,6 +350,7 @@ public Action:Command_Rcon(client, args)
|
|||||||
GetCmdArgString(argstring, sizeof(argstring));
|
GetCmdArgString(argstring, sizeof(argstring));
|
||||||
|
|
||||||
LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
|
LogMessage("\"%L\" console command (cmdline \"%s\")", client, argstring);
|
||||||
|
|
||||||
ServerCommand("%s", argstring);
|
ServerCommand("%s", argstring);
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
@ -290,9 +373,9 @@ public Action:Command_Map(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("\"%L\" changed map to \"%s\"", client, map);
|
|
||||||
ShowActivity(client, "%t", "Changing map", map);
|
ShowActivity(client, "%t", "Changing map", map);
|
||||||
ReplyToCommand(client, "%t", "Changing map", map);
|
|
||||||
|
LogMessage("\"%L\" changed map to \"%s\"", client, map);
|
||||||
|
|
||||||
new Handle:dp;
|
new Handle:dp;
|
||||||
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
CreateDataTimer(3.0, Timer_ChangeMap, dp);
|
||||||
@ -336,6 +419,7 @@ public Action:Command_Kick(client, args)
|
|||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
} else if (!CanUserTarget(client, clients[0])) {
|
} else if (!CanUserTarget(client, clients[0])) {
|
||||||
ReplyToCommand(client, "[SM] %t", "Unable to target");
|
ReplyToCommand(client, "[SM] %t", "Unable to target");
|
||||||
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
|
||||||
new userid = GetClientUserId(clients[0]);
|
new userid = GetClientUserId(clients[0]);
|
||||||
@ -352,9 +436,10 @@ public Action:Command_Kick(client, args)
|
|||||||
GetCmdArg(2, reason, sizeof(reason));
|
GetCmdArg(2, reason, sizeof(reason));
|
||||||
}
|
}
|
||||||
|
|
||||||
LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
|
|
||||||
ShowActivity(client, "%t", "Kicked player", name);
|
ShowActivity(client, "%t", "Kicked player", name);
|
||||||
|
|
||||||
|
LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
|
||||||
|
|
||||||
if (args < 2)
|
if (args < 2)
|
||||||
{
|
{
|
||||||
ServerCommand("kickid %d", userid);
|
ServerCommand("kickid %d", userid);
|
||||||
@ -362,7 +447,5 @@ public Action:Command_Kick(client, args)
|
|||||||
ServerCommand("kickid %d \"%s\"", userid, reason);
|
ServerCommand("kickid %d \"%s\"", userid, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
ReplyToCommand(client, "[SM] %t", "Client kicked", name);
|
|
||||||
|
|
||||||
return Plugin_Handled;
|
return Plugin_Handled;
|
||||||
}
|
}
|
||||||
|
@ -185,7 +185,9 @@ native ReplySource:GetCmdReplySource();
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Displays usage of an admin command to users depending on the
|
* Displays usage of an admin command to users depending on the
|
||||||
* setting of the sm_show_activity cvar.
|
* setting of the sm_show_activity cvar. Additionally, the client
|
||||||
|
* who typed the command will receive the same text without any
|
||||||
|
* client name prefix (as a confirmation).
|
||||||
*
|
*
|
||||||
* @param client Client index doing the action, or 0 for server.
|
* @param client Client index doing the action, or 0 for server.
|
||||||
* @param format Formatting rules.
|
* @param format Formatting rules.
|
||||||
|
@ -17,12 +17,6 @@
|
|||||||
"en" "Kicked player '{1}'"
|
"en" "Kicked player '{1}'"
|
||||||
}
|
}
|
||||||
|
|
||||||
"Client kicked"
|
|
||||||
{
|
|
||||||
"#format" "{1:s}"
|
|
||||||
"en" "Client '{1}' kicked."
|
|
||||||
}
|
|
||||||
|
|
||||||
"Changing map"
|
"Changing map"
|
||||||
{
|
{
|
||||||
"#format" "{1:s}"
|
"#format" "{1:s}"
|
||||||
@ -54,4 +48,9 @@
|
|||||||
{
|
{
|
||||||
"en" "See console for output."
|
"en" "See console for output."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Cannot target bot"
|
||||||
|
{
|
||||||
|
"en" "Unable to perform this command on a bot."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -34,4 +34,28 @@
|
|||||||
"#format" "{1:s}"
|
"#format" "{1:s}"
|
||||||
"en" "Executed config '{1}'."
|
"en" "Executed config '{1}'."
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"Permabanned player"
|
||||||
|
{
|
||||||
|
"#format" "{1:s}"
|
||||||
|
"en" "Permanently banned player '{1}'."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Permabanned player reason"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:s}"
|
||||||
|
"en" "Permanently banned player '{1}' (reason: {2})."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Banned player"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:d}"
|
||||||
|
"en" "Banned player '{1}' for {2} minutes."
|
||||||
|
}
|
||||||
|
|
||||||
|
"Banned player reason"
|
||||||
|
{
|
||||||
|
"#format" "{1:s},{2:d},{3:s}"
|
||||||
|
"en" "Banned player '{1}' for {2} minutes (reason: {3})."
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user