1.1 --- a/core/smn_player.cpp Thu Jun 07 06:16:38 2007 +0000
1.2 +++ b/core/smn_player.cpp Thu Jun 07 06:17:57 2007 +0000
1.3 @@ -15,8 +15,12 @@
1.4 #include "PlayerManager.h"
1.5 #include "AdminCache.h"
1.6 #include "sm_stringutil.h"
1.7 +#include "HalfLife2.h"
1.8 +#include "sourcemod.h"
1.9 #include <inetchannelinfo.h>
1.10
1.11 +ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY, "Activity display setting (see sourcemod.cfg)");
1.12 +
1.13 static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
1.14 {
1.15 if (params[1])
1.16 @@ -816,6 +820,84 @@
1.17 return g_Players.GetClientOfUserId(params[1]);
1.18 }
1.19
1.20 +static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
1.21 +{
1.22 + int value = sm_show_activity.GetInt();
1.23 +
1.24 + if (!value)
1.25 + {
1.26 + return 0;
1.27 + }
1.28 +
1.29 + int client = params[1];
1.30 +
1.31 + const char *name = "Console";
1.32 + const char *sign = "ADMIN";
1.33 + if (client != 0)
1.34 + {
1.35 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
1.36 + if (!pPlayer || !pPlayer->IsConnected())
1.37 + {
1.38 + return pContext->ThrowNativeError("Client index %d is invalid", client);
1.39 + }
1.40 + name = pPlayer->GetName();
1.41 + AdminId id = pPlayer->GetAdminId();
1.42 + if (id == INVALID_ADMIN_ID
1.43 + || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
1.44 + {
1.45 + sign = "PLAYER";
1.46 + }
1.47 + }
1.48 +
1.49 + char message[255];
1.50 + char buffer[255];
1.51 + int maxClients = g_Players.GetMaxClients();
1.52 + for (int i=1; i<=maxClients; i++)
1.53 + {
1.54 + CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
1.55 + if (!pPlayer->IsInGame() || pPlayer->IsFakeClient())
1.56 + {
1.57 + continue;
1.58 + }
1.59 + AdminId id = pPlayer->GetAdminId();
1.60 + g_SourceMod.SetGlobalTarget(i);
1.61 + if (id == INVALID_ADMIN_ID
1.62 + || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
1.63 + {
1.64 + /* Treat this as a normal user */
1.65 + if ((value & 1) || (value & 2))
1.66 + {
1.67 + const char *newsign = sign;
1.68 + if (value & 2)
1.69 + {
1.70 + newsign = name;
1.71 + }
1.72 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
1.73 + UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
1.74 + g_HL2.TextMsg(i, HUD_PRINTTALK, message);
1.75 + }
1.76 + } else {
1.77 + /* Treat this as an admin user */
1.78 + bool is_root = g_Admins.GetAdminFlag(id, Admin_Root, Access_Effective);
1.79 + if ((value & 4)
1.80 + || (value & 8)
1.81 + || ((value & 16) && is_root))
1.82 + {
1.83 + const char *newsign = sign;
1.84 + if ((value & 8) || ((value & 16) && is_root))
1.85 + {
1.86 + newsign = name;
1.87 + }
1.88 + g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
1.89 + UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
1.90 + g_HL2.TextMsg(i, HUD_PRINTTALK, message);
1.91 + }
1.92 + }
1.93 + }
1.94 +
1.95 + return 1;
1.96 +}
1.97 +
1.98 REGISTER_NATIVES(playernatives)
1.99 {
1.100 {"AddUserFlags", AddUserFlags},
1.101 @@ -858,5 +940,6 @@
1.102 {"GetClientAvgData", GetAvgData},
1.103 {"GetClientAvgPackets", GetAvgPackets},
1.104 {"GetClientOfUserId", GetClientOfUserId},
1.105 + {"ShowActivity", ShowActivity},
1.106 {NULL, NULL}
1.107 };