1.1 --- a/core/smn_console.cpp Thu Jun 07 06:16:38 2007 +0000
1.2 +++ b/core/smn_console.cpp Thu Jun 07 06:17:57 2007 +0000
1.3 @@ -686,6 +686,8 @@
1.4 return pContext->ThrowNativeError("Client %d is not connected", params[1]);
1.5 }
1.6
1.7 + g_SourceMod.SetGlobalTarget(params[1]);
1.8 +
1.9 unsigned int replyto = g_ChatTriggers.GetReplyTo();
1.10 if (replyto == SM_REPLY_CONSOLE)
1.11 {
2.1 --- a/core/smn_player.cpp Thu Jun 07 06:16:38 2007 +0000
2.2 +++ b/core/smn_player.cpp Thu Jun 07 06:17:57 2007 +0000
2.3 @@ -15,8 +15,12 @@
2.4 #include "PlayerManager.h"
2.5 #include "AdminCache.h"
2.6 #include "sm_stringutil.h"
2.7 +#include "HalfLife2.h"
2.8 +#include "sourcemod.h"
2.9 #include <inetchannelinfo.h>
2.10
2.11 +ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
2.12 +
2.13 static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
2.14 {
2.15 if (params[1])
2.16 @@ -816,6 +820,84 @@
2.17 return g_Players.GetClientOfUserId(params[1]);
2.18 }
2.19
2.20 +static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
2.21 +{
2.22 + int value = sm_show_activity.GetInt();
2.23 +
2.24 + if (!value)
2.25 + {
2.26 + return 0;
2.27 + }
2.28 +
2.29 + int client = params[1];
2.30 +
2.31 + const char *name = "Console";
2.32 + const char *sign = "ADMIN";
2.33 + if (client != 0)
2.34 + {
2.35 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
2.36 + if (!pPlayer || !pPlayer->IsConnected())
2.37 + {
2.38 + return pContext->ThrowNativeError("Client index %d is invalid", client);
2.39 + }
2.40 + name = pPlayer->GetName();
2.41 + AdminId id = pPlayer->GetAdminId();
2.42 + if (id == INVALID_ADMIN_ID
2.43 + || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
2.44 + {
2.45 + sign = "PLAYER";
2.46 + }
2.47 + }
2.48 +
2.49 + char message[255];
2.50 + char buffer[255];
2.51 + int maxClients = g_Players.GetMaxClients();
2.52 + for (int i=1; i<=maxClients; i++)
2.53 + {
2.54 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
2.55 + if (!pPlayer->IsInGame() || pPlayer->IsFakeClient())
2.56 + {
2.57 + continue;
2.58 + }
2.59 + AdminId id = pPlayer->GetAdminId();
2.60 + g_SourceMod.SetGlobalTarget(i);
2.61 + if (id == INVALID_ADMIN_ID
2.62 + || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
2.63 + {
2.64 + /* Treat this as a normal user */
2.65 + if ((value & 1) || (value & 2))
2.66 + {
2.67 + const char *newsign = sign;
2.68 + if (value & 2)
2.69 + {
2.70 + newsign = name;
2.71 + }
2.72 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
2.73 + UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
2.74 + g_HL2.TextMsg(i, HUD_PRINTTALK, message);
2.75 + }
2.76 + } else {
2.77 + /* Treat this as an admin user */
2.78 + bool is_root = g_Admins.GetAdminFlag(id, Admin_Root, Access_Effective);
2.79 + if ((value & 4)
2.80 + || (value & 8)
2.81 + || ((value & 16) && is_root))
2.82 + {
2.83 + const char *newsign = sign;
2.84 + if ((value & 8) || ((value & 16) && is_root))
2.85 + {
2.86 + newsign = name;
2.87 + }
2.88 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
2.89 + UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
2.90 + g_HL2.TextMsg(i, HUD_PRINTTALK, message);
2.91 + }
2.92 + }
2.93 + }
2.94 +
2.95 + return 1;
2.96 +}
2.97 +
2.98 REGISTER_NATIVES(playernatives)
2.99 {
2.100 {"AddUserFlags", AddUserFlags},
2.101 @@ -858,5 +940,6 @@
2.102 {"GetClientAvgData", GetAvgData},
2.103 {"GetClientAvgPackets", GetAvgPackets},
2.104 {"GetClientOfUserId", GetClientOfUserId},
2.105 + {"ShowActivity", ShowActivity},
2.106 {NULL, NULL}
2.107 };
3.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
3.2 +++ b/plugins/basecommands.sp Thu Jun 07 06:17:57 2007 +0000
3.3 @@ -0,0 +1,88 @@
3.4 +/**
3.5 + * admincmds-basic.sp
3.6 + * Manages the standard flat files for admins. This is the file to compile.
3.7 + * This file is part of SourceMod, Copyright (C) 2004-2007 AlliedModders LLC
3.8 + *
3.9 + * This program is free software; you can redistribute it and/or
3.10 + * modify it under the terms of the GNU General Public License
3.11 + * as published by the Free Software Foundation; either version 2
3.12 + * of the License, or (at your option) any later version.
3.13 + *
3.14 + * This program is distributed in the hope that it will be useful,
3.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
3.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
3.17 + * GNU General Public License for more details.
3.18 + *
3.19 + * You should have received a copy of the GNU General Public License
3.20 + * along with this program; if not, write to the Free Software
3.21 + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
3.22 + */
3.23 +
3.24 +#include <sourcemod>
3.25 +
3.26 +public Plugin:myinfo =
3.27 +{
3.28 + name = "Basic Commands",
3.29 + author = "AlliedModders LLC",
3.30 + description = "Basic Admin Commands",
3.31 + version = SOURCEMOD_VERSION,
3.32 + url = "http://www.sourcemod.net/"
3.33 +};
3.34 +
3.35 +public OnPluginStart()
3.36 +{
3.37 + LoadTranslations("core.cfg");
3.38 + RegAdminCmd("sm_kick", Command_Kick, ADMFLAG_KICK, "sm_kick <#userid|name> [reason]");
3.39 +}
3.40 +
3.41 +public Action:Command_Kick(client, args)
3.42 +{
3.43 + if (args < 1)
3.44 + {
3.45 + ReplyToCommand(client, "[SM] Usage: sm_kick <#userid|name> [reason]");
3.46 + return Plugin_Handled;
3.47 + }
3.48 +
3.49 + new String:arg[65];
3.50 + GetCmdArg(1, arg, sizeof(arg));
3.51 +
3.52 + new clients[2];
3.53 + new numClients = SearchForClients(arg, clients, 2);
3.54 +
3.55 + if (numClients == 0)
3.56 + {
3.57 + ReplyToCommand(client, "[SM] %t", "No matching client");
3.58 + return Plugin_Handled;
3.59 + } else if (numClients > 1) {
3.60 + ReplyToCommand(client, "[SM] %t", "More than one client matches", arg);
3.61 + return Plugin_Handled;
3.62 + }
3.63 +
3.64 + new userid = GetClientUserId(clients[0]);
3.65 + new String:name[65];
3.66 +
3.67 + GetClientName(clients[0], name, sizeof(name));
3.68 +
3.69 + decl String:reason[256]
3.70 + if (args < 2)
3.71 + {
3.72 + /* Safely null terminate */
3.73 + reason[0] = '\0';
3.74 + } else {
3.75 + GetCmdArg(2, reason, sizeof(reason));
3.76 + }
3.77 +
3.78 + LogMessage("\"%L\" kicked \"%L\" (reason \"%s\")", client, clients[0], reason);
3.79 + ShowActivity(client, "%t", "Kicked player", name);
3.80 +
3.81 + if (args < 2)
3.82 + {
3.83 + ServerCommand("kickid %d", userid);
3.84 + } else {
3.85 + ServerCommand("kickid %d \"%s\"", userid, reason);
3.86 + }
3.87 +
3.88 + ReplyToCommand(client, "[SM] Client \"%s\" kicked.", name);
3.89 +
3.90 + return Plugin_Handled;
3.91 +}
4.1 --- a/plugins/include/console.inc Thu Jun 07 06:16:38 2007 +0000
4.2 +++ b/plugins/include/console.inc Thu Jun 07 06:17:57 2007 +0000
4.3 @@ -165,7 +165,19 @@
4.4 * @noreturn
4.5 * @error If the client is not connected or invalid.
4.6 */
4.7 -native ReplyToCommand(client, const String:fornmat[], any:...);
4.8 +native ReplyToCommand(client, const String:format[], any:...);
4.9 +
4.10 +/**
4.11 + * Displays usage of an admin command to users depending on the
4.12 + * setting of the sm_show_activity cvar.
4.13 + *
4.14 + * @param client Client index doing the action, or 0 for server.
4.15 + * @param format Formatting rules.
4.16 + * @param ... Variable number of format parameters.
4.17 + * @noreturn
4.18 + * @error
4.19 + */
4.20 +native ShowActivity(client, const String:format[], any:...);
4.21
4.22 /**
4.23 * Called when a server-only command is invoked.
5.1 --- a/plugins/include/sourcemod.inc Thu Jun 07 06:16:38 2007 +0000
5.2 +++ b/plugins/include/sourcemod.inc Thu Jun 07 06:17:57 2007 +0000
5.3 @@ -46,6 +46,7 @@
5.4 #include <bitbuffer>
5.5 #include <usermessages>
5.6 #include <menus>
5.7 +#include <lang>
5.8 #include <halflife>
5.9
5.10 /**