fixed a bug where menu handler used wrong variable for param2 bitmask in MenuVoteEnd
3 * ===============================================================
4 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
5 * ===============================================================
7 * This file is not open source and may not be copied without explicit
8 * written permission of AlliedModders LLC. This file may not be redistributed
9 * in whole or significant part.
10 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
15 #include "PlayerManager.h"
16 #include "AdminCache.h"
17 #include "sm_stringutil.h"
18 #include "HalfLife2.h"
19 #include "sourcemod.h"
20 #include <inetchannelinfo.h>
21 #include "ChatTriggers.h"
23 ConVar sm_show_activity("sm_show_activity", "13", FCVAR_SPONLY|FCVAR_PROTECTED, "Activity display setting (see sourcemod.cfg)");
25 static cell_t sm_GetClientCount(IPluginContext *pCtx, const cell_t *params)
29 return g_Players.NumPlayers();
32 int maxplayers = g_Players.MaxClients();
34 for (int i=1; i<=maxplayers; ++i)
36 CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
37 if ((pPlayer->IsConnected()) && !(pPlayer->IsInGame()))
43 return (g_Players.NumPlayers() + count);
46 static cell_t sm_GetMaxClients(IPluginContext *pCtx, const cell_t *params)
48 return g_Players.MaxClients();
51 static cell_t sm_GetClientName(IPluginContext *pCtx, const cell_t *params)
53 int index = params[1];
54 if ((index < 1) || (index > g_Players.GetMaxClients()))
56 return pCtx->ThrowNativeError("Invalid client index %d", index);
59 CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
60 if (!pPlayer->IsConnected())
62 return pCtx->ThrowNativeError("Client %d is not connected", index);
65 pCtx->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), pPlayer->GetName(), NULL);
69 static cell_t sm_GetClientIP(IPluginContext *pCtx, const cell_t *params)
71 int index = params[1];
72 if ((index < 1) || (index > g_Players.GetMaxClients()))
74 return pCtx->ThrowNativeError("Invalid client index %d", index);
77 CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
78 if (!pPlayer->IsConnected())
80 return pCtx->ThrowNativeError("Client %d is not connected", index);
84 strcpy(buf, pPlayer->GetIPAddress());
86 if (params[4] && (ptr = strchr(buf, ':')))
91 pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), buf);
95 static cell_t sm_GetClientAuthStr(IPluginContext *pCtx, const cell_t *params)
97 int index = params[1];
98 if ((index < 1) || (index > g_Players.GetMaxClients()))
100 return pCtx->ThrowNativeError("Invalid client index %d", index);
103 CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
104 if (!pPlayer->IsConnected())
106 return pCtx->ThrowNativeError("Client %d is not connected", index);
109 if (!pPlayer->IsAuthorized())
114 pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), pPlayer->GetAuthString());
119 static cell_t sm_IsClientConnected(IPluginContext *pCtx, const cell_t *params)
121 int index = params[1];
122 if ((index < 1) || (index > g_Players.GetMaxClients()))
124 return pCtx->ThrowNativeError("Invalid client index %d", index);
127 return (g_Players.GetPlayerByIndex(index)->IsConnected()) ? 1 : 0;
130 static cell_t sm_IsClientInGame(IPluginContext *pCtx, const cell_t *params)
132 int index = params[1];
133 if ((index < 1) || (index > g_Players.GetMaxClients()))
135 return pCtx->ThrowNativeError("Invalid client index %d", index);
138 return (g_Players.GetPlayerByIndex(index)->IsInGame()) ? 1 : 0;
141 static cell_t sm_IsClientAuthorized(IPluginContext *pCtx, const cell_t *params)
143 int index = params[1];
144 if ((index < 1) || (index > g_Players.GetMaxClients()))
146 return pCtx->ThrowNativeError("Invalid client index %d", index);
149 return (g_Players.GetPlayerByIndex(index)->IsAuthorized()) ? 1 : 0;
152 static cell_t sm_IsClientFakeClient(IPluginContext *pCtx, const cell_t *params)
154 int index = params[1];
155 if ((index < 1) || (index > g_Players.GetMaxClients()))
157 return pCtx->ThrowNativeError("Invalid client index %d", index);
160 CPlayer *pPlayer = g_Players.GetPlayerByIndex(index);
161 if (!pPlayer->IsConnected())
163 return pCtx->ThrowNativeError("Client %d is not connected", index);
166 return (pPlayer->IsFakeClient()) ? 1 : 0;
169 static cell_t sm_GetClientInfo(IPluginContext *pContext, const cell_t *params)
171 int client = params[1];
172 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
175 return pContext->ThrowNativeError("Invalid client index %d", client);
177 if (!pPlayer->IsConnected())
179 return pContext->ThrowNativeError("Client %d is not connected", client);
183 pContext->LocalToString(params[2], &key);
185 const char *val = engine->GetClientConVarValue(client, key);
191 pContext->StringToLocalUTF8(params[3], params[4], val, NULL);
195 static cell_t SetUserAdmin(IPluginContext *pContext, const cell_t *params)
197 int client = params[1];
198 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
201 return pContext->ThrowNativeError("Invalid client index %d", client);
203 if (!pPlayer->IsConnected())
205 return pContext->ThrowNativeError("Client %d is not connected", client);
207 if (!g_Admins.IsValidAdmin(params[2]))
209 return pContext->ThrowNativeError("AdminId %x is not valid", params[2]);
212 pPlayer->SetAdminId(params[2], params[3] ? true : false);
217 static cell_t GetUserAdmin(IPluginContext *pContext, const cell_t *params)
219 int client = params[1];
220 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
223 return pContext->ThrowNativeError("Invalid client index %d", client);
225 if (!pPlayer->IsConnected())
227 return pContext->ThrowNativeError("Client %d is not connected", client);
230 return pPlayer->GetAdminId();
233 static cell_t AddUserFlags(IPluginContext *pContext, const cell_t *params)
235 int client = params[1];
236 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
239 return pContext->ThrowNativeError("Invalid client index %d", client);
241 if (!pPlayer->IsConnected())
243 return pContext->ThrowNativeError("Client %d is not connected", client);
247 if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
249 id = g_Admins.CreateAdmin(NULL);
250 pPlayer->SetAdminId(id, true);
254 for (int i=2; i<=params[0]; i++)
256 pContext->LocalToPhysAddr(params[i], &addr);
257 g_Admins.SetAdminFlag(id, (AdminFlag)*addr, true);
263 static cell_t RemoveUserFlags(IPluginContext *pContext, const cell_t *params)
265 int client = params[1];
266 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
269 return pContext->ThrowNativeError("Invalid client index %d", client);
271 if (!pPlayer->IsConnected())
273 return pContext->ThrowNativeError("Client %d is not connected", client);
277 if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
283 for (int i=2; i<=params[0]; i++)
285 pContext->LocalToPhysAddr(params[i], &addr);
286 g_Admins.SetAdminFlag(id, (AdminFlag)*addr, false);
292 static cell_t SetUserFlagBits(IPluginContext *pContext, const cell_t *params)
294 int client = params[1];
295 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
298 return pContext->ThrowNativeError("Invalid client index %d", client);
300 if (!pPlayer->IsConnected())
302 return pContext->ThrowNativeError("Client %d is not connected", client);
306 if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
308 id = g_Admins.CreateAdmin(NULL);
309 pPlayer->SetAdminId(id, true);
312 g_Admins.SetAdminFlags(id, Access_Effective, params[2]);
317 static cell_t GetUserFlagBits(IPluginContext *pContext, const cell_t *params)
319 int client = params[1];
320 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
323 return pContext->ThrowNativeError("Invalid client index %d", client);
325 if (!pPlayer->IsConnected())
327 return pContext->ThrowNativeError("Client %d is not connected", client);
331 if ((id=pPlayer->GetAdminId()) == INVALID_ADMIN_ID)
336 return g_Admins.GetAdminFlags(id, Access_Effective);
339 static cell_t GetClientUserId(IPluginContext *pContext, const cell_t *params)
341 int client = params[1];
342 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
345 return pContext->ThrowNativeError("Invalid client index %d", client);
347 if (!pPlayer->IsConnected())
349 return pContext->ThrowNativeError("Client %d is not connected", client);
352 return engine->GetPlayerUserId(pPlayer->GetEdict());
355 static cell_t CanUserTarget(IPluginContext *pContext, const cell_t *params)
357 int client = params[1];
358 int target = params[2];
360 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
363 return pContext->ThrowNativeError("Player %d is not a valid client", client);
364 } else if (!pPlayer->IsConnected()) {
365 return pContext->ThrowNativeError("Player %d is not connected", client);
368 CPlayer *pTarget = g_Players.GetPlayerByIndex(target);
371 return pContext->ThrowNativeError("Player %d is not a valid client", target);
372 } else if (!pTarget->IsConnected()) {
373 return pContext->ThrowNativeError("Player %d is not connected", target);
376 return g_Admins.CanAdminTarget(pPlayer->GetAdminId(), pTarget->GetAdminId()) ? 1 : 0;
379 static cell_t GetClientTeam(IPluginContext *pContext, const cell_t *params)
381 int client = params[1];
383 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
386 return pContext->ThrowNativeError("Player %d is not a valid client", client);
387 } else if (!pPlayer->IsInGame()) {
388 return pContext->ThrowNativeError("Player %d is not in game", client);
391 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
394 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
397 return pInfo->GetTeamIndex();
400 static cell_t GetFragCount(IPluginContext *pContext, const cell_t *params)
402 int client = params[1];
404 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
407 return pContext->ThrowNativeError("Player %d is not a valid client", client);
408 } else if (!pPlayer->IsInGame()) {
409 return pContext->ThrowNativeError("Player %d is not in game", client);
412 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
415 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
418 return pInfo->GetFragCount();
421 static cell_t GetDeathCount(IPluginContext *pContext, const cell_t *params)
423 int client = params[1];
425 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
428 return pContext->ThrowNativeError("Player %d is not a valid client", client);
429 } else if (!pPlayer->IsInGame()) {
430 return pContext->ThrowNativeError("Player %d is not in game", client);
433 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
436 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
439 return pInfo->GetDeathCount();
442 static cell_t GetArmorValue(IPluginContext *pContext, const cell_t *params)
444 int client = params[1];
446 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
449 return pContext->ThrowNativeError("Player %d is not a valid client", client);
450 } else if (!pPlayer->IsInGame()) {
451 return pContext->ThrowNativeError("Player %d is not in game", client);
454 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
457 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
460 return pInfo->GetArmorValue();
463 static cell_t GetAbsOrigin(IPluginContext *pContext, const cell_t *params)
465 int client = params[1];
467 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
470 return pContext->ThrowNativeError("Player %d is not a valid client", client);
471 } else if (!pPlayer->IsInGame()) {
472 return pContext->ThrowNativeError("Player %d is not in game", client);
475 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
478 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
482 pContext->LocalToPhysAddr(params[2], &pVec);
484 Vector vec = pInfo->GetAbsOrigin();
485 pVec[0] = sp_ftoc(vec.x);
486 pVec[1] = sp_ftoc(vec.y);
487 pVec[2] = sp_ftoc(vec.z);
492 static cell_t GetAbsAngles(IPluginContext *pContext, const cell_t *params)
494 int client = params[1];
496 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
499 return pContext->ThrowNativeError("Player %d is not a valid client", client);
500 } else if (!pPlayer->IsInGame()) {
501 return pContext->ThrowNativeError("Player %d is not in game", client);
504 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
507 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
511 pContext->LocalToPhysAddr(params[2], &pAng);
513 QAngle ang = pInfo->GetAbsAngles();
514 pAng[0] = sp_ftoc(ang.x);
515 pAng[1] = sp_ftoc(ang.y);
516 pAng[2] = sp_ftoc(ang.z);
521 static cell_t GetPlayerMins(IPluginContext *pContext, const cell_t *params)
523 int client = params[1];
525 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
528 return pContext->ThrowNativeError("Player %d is not a valid client", client);
529 } else if (!pPlayer->IsInGame()) {
530 return pContext->ThrowNativeError("Player %d is not in game", client);
533 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
536 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
540 pContext->LocalToPhysAddr(params[2], &pVec);
542 Vector vec = pInfo->GetPlayerMins();
543 pVec[0] = sp_ftoc(vec.x);
544 pVec[1] = sp_ftoc(vec.y);
545 pVec[2] = sp_ftoc(vec.z);
550 static cell_t GetPlayerMaxs(IPluginContext *pContext, const cell_t *params)
552 int client = params[1];
554 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
557 return pContext->ThrowNativeError("Player %d is not a valid client", client);
558 } else if (!pPlayer->IsInGame()) {
559 return pContext->ThrowNativeError("Player %d is not in game", client);
562 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
565 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
569 pContext->LocalToPhysAddr(params[2], &pVec);
571 Vector vec = pInfo->GetPlayerMaxs();
572 pVec[0] = sp_ftoc(vec.x);
573 pVec[1] = sp_ftoc(vec.y);
574 pVec[2] = sp_ftoc(vec.z);
579 static cell_t GetWeaponName(IPluginContext *pContext, const cell_t *params)
581 int client = params[1];
583 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
586 return pContext->ThrowNativeError("Player %d is not a valid client", client);
587 } else if (!pPlayer->IsInGame()) {
588 return pContext->ThrowNativeError("Player %d is not in game", client);
591 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
594 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
597 const char *weapon = pInfo->GetWeaponName();
598 pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), weapon ? weapon : "", NULL);
603 static cell_t GetModelName(IPluginContext *pContext, const cell_t *params)
605 int client = params[1];
607 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
610 return pContext->ThrowNativeError("Player %d is not a valid client", client);
611 } else if (!pPlayer->IsInGame()) {
612 return pContext->ThrowNativeError("Player %d is not in game", client);
615 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
618 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
621 const char *model = pInfo->GetModelName();
622 pContext->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), model ? model : "", NULL);
627 static cell_t GetHealth(IPluginContext *pContext, const cell_t *params)
629 int client = params[1];
631 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
634 return pContext->ThrowNativeError("Player %d is not a valid client", client);
635 } else if (!pPlayer->IsInGame()) {
636 return pContext->ThrowNativeError("Player %d is not in game", client);
639 IPlayerInfo *pInfo = pPlayer->GetPlayerInfo();
642 return pContext->ThrowNativeError("IPlayerInfo not supported by game");
645 return pInfo->GetHealth();
648 static cell_t GetTimeConnected(IPluginContext *pContext, const cell_t *params)
650 int client = params[1];
652 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
655 return pContext->ThrowNativeError("Player %d is not a valid client", client);
656 } else if (!pPlayer->IsInGame()) {
657 return pContext->ThrowNativeError("Player %d is not in game", client);
658 } else if (pPlayer->IsFakeClient()) {
659 return pContext->ThrowNativeError("Player %d is a bot", client);
662 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
664 return sp_ftoc(pInfo->GetTimeConnected());
667 static cell_t GetDataRate(IPluginContext *pContext, const cell_t *params)
669 int client = params[1];
671 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
674 return pContext->ThrowNativeError("Player %d is not a valid client", client);
675 } else if (!pPlayer->IsInGame()) {
676 return pContext->ThrowNativeError("Player %d is not in game", client);
677 } else if (pPlayer->IsFakeClient()) {
678 return pContext->ThrowNativeError("Player %d is a bot", client);
681 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
683 return pInfo->GetDataRate();
686 static cell_t IsTimingOut(IPluginContext *pContext, const cell_t *params)
688 int client = params[1];
690 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
693 return pContext->ThrowNativeError("Player %d is not a valid client", client);
694 } else if (!pPlayer->IsInGame()) {
695 return pContext->ThrowNativeError("Player %d is not in game", client);
696 } else if (pPlayer->IsFakeClient()) {
697 return pContext->ThrowNativeError("Player %d is a bot", client);
700 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
702 return pInfo->IsTimingOut() ? 1 : 0;
705 static cell_t GetLatency(IPluginContext *pContext, const cell_t *params)
707 int client = params[1];
709 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
712 return pContext->ThrowNativeError("Player %d is not a valid client", client);
713 } else if (!pPlayer->IsInGame()) {
714 return pContext->ThrowNativeError("Player %d is not in game", client);
715 } else if (pPlayer->IsFakeClient()) {
716 return pContext->ThrowNativeError("Player %d is a bot", client);
719 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
721 return sp_ftoc(pInfo->GetLatency(params[2]));
724 static cell_t GetAvgLatency(IPluginContext *pContext, const cell_t *params)
726 int client = params[1];
728 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
731 return pContext->ThrowNativeError("Player %d is not a valid client", client);
732 } else if (!pPlayer->IsInGame()) {
733 return pContext->ThrowNativeError("Player %d is not in game", client);
734 } else if (pPlayer->IsFakeClient()) {
735 return pContext->ThrowNativeError("Player %d is a bot", client);
738 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
740 return sp_ftoc(pInfo->GetAvgLatency(params[2]));
743 static cell_t GetAvgLoss(IPluginContext *pContext, const cell_t *params)
745 int client = params[1];
747 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
750 return pContext->ThrowNativeError("Player %d is not a valid client", client);
751 } else if (!pPlayer->IsInGame()) {
752 return pContext->ThrowNativeError("Player %d is not in game", client);
753 } else if (pPlayer->IsFakeClient()) {
754 return pContext->ThrowNativeError("Player %d is a bot", client);
757 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
759 return sp_ftoc(pInfo->GetAvgLoss(params[2]));
762 static cell_t GetAvgChoke(IPluginContext *pContext, const cell_t *params)
764 int client = params[1];
766 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
769 return pContext->ThrowNativeError("Player %d is not a valid client", client);
770 } else if (!pPlayer->IsInGame()) {
771 return pContext->ThrowNativeError("Player %d is not in game", client);
772 } else if (pPlayer->IsFakeClient()) {
773 return pContext->ThrowNativeError("Player %d is a bot", client);
776 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
778 return sp_ftoc(pInfo->GetAvgChoke(params[2]));
781 static cell_t GetAvgData(IPluginContext *pContext, const cell_t *params)
783 int client = params[1];
785 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
788 return pContext->ThrowNativeError("Player %d is not a valid client", client);
789 } else if (!pPlayer->IsInGame()) {
790 return pContext->ThrowNativeError("Player %d is not in game", client);
791 } else if (pPlayer->IsFakeClient()) {
792 return pContext->ThrowNativeError("Player %d is a bot", client);
795 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
797 return sp_ftoc(pInfo->GetAvgData(params[2]));
800 static cell_t GetAvgPackets(IPluginContext *pContext, const cell_t *params)
802 int client = params[1];
804 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
807 return pContext->ThrowNativeError("Player %d is not a valid client", client);
808 } else if (!pPlayer->IsInGame()) {
809 return pContext->ThrowNativeError("Player %d is not in game", client);
810 } else if (pPlayer->IsFakeClient()) {
811 return pContext->ThrowNativeError("Player %d is a bot", client);
814 INetChannelInfo *pInfo = engine->GetPlayerNetInfo(client);
816 return sp_ftoc(pInfo->GetAvgPackets(params[2]));
819 static cell_t GetClientOfUserId(IPluginContext *pContext, const cell_t *params)
821 return g_Players.GetClientOfUserId(params[1]);
824 static cell_t ShowActivity(IPluginContext *pContext, const cell_t *params)
828 int value = sm_show_activity.GetInt();
829 unsigned int replyto = g_ChatTriggers.GetReplyTo();
830 int client = params[1];
832 const char *name = "Console";
833 const char *sign = "ADMIN";
834 bool display_in_chat = false;
837 CPlayer *pPlayer = g_Players.GetPlayerByIndex(client);
838 if (!pPlayer || !pPlayer->IsConnected())
840 return pContext->ThrowNativeError("Client index %d is invalid", client);
842 name = pPlayer->GetName();
843 AdminId id = pPlayer->GetAdminId();
844 if (id == INVALID_ADMIN_ID
845 || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
850 /* Display the message to the client? */
851 if (replyto == SM_REPLY_CONSOLE)
853 g_SourceMod.SetGlobalTarget(client);
854 g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
855 UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
856 engine->ClientPrintf(pPlayer->GetEdict(), message);
857 display_in_chat = true;
860 g_SourceMod.SetGlobalTarget(LANG_SERVER);
861 g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
862 UTIL_Format(message, sizeof(message), "[SM] %s\n", buffer);
863 META_CONPRINT(message);
871 int maxClients = g_Players.GetMaxClients();
872 for (int i=1; i<=maxClients; i++)
874 CPlayer *pPlayer = g_Players.GetPlayerByIndex(i);
875 if (!pPlayer->IsInGame()
876 || pPlayer->IsFakeClient()
877 || (display_in_chat && i == client))
881 AdminId id = pPlayer->GetAdminId();
882 g_SourceMod.SetGlobalTarget(i);
883 if (id == INVALID_ADMIN_ID
884 || !g_Admins.GetAdminFlag(id, Admin_Generic, Access_Effective))
886 /* Treat this as a normal user */
887 if ((value & 1) || (value & 2))
889 const char *newsign = sign;
894 g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
895 UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
896 g_HL2.TextMsg(i, HUD_PRINTTALK, message);
899 /* Treat this as an admin user */
900 bool is_root = g_Admins.GetAdminFlag(id, Admin_Root, Access_Effective);
903 || ((value & 16) && is_root))
905 const char *newsign = sign;
906 if ((value & 8) || ((value & 16) && is_root))
910 g_SourceMod.FormatString(buffer, sizeof(buffer), pContext, params, 2);
911 UTIL_Format(message, sizeof(message), "[SM] %s: %s", newsign, buffer);
912 g_HL2.TextMsg(i, HUD_PRINTTALK, message);
920 REGISTER_NATIVES(playernatives)
922 {"AddUserFlags", AddUserFlags},
923 {"CanUserTarget", CanUserTarget},
924 {"GetClientAuthString", sm_GetClientAuthStr},
925 {"GetClientCount", sm_GetClientCount},
926 {"GetClientInfo", sm_GetClientInfo},
927 {"GetClientIP", sm_GetClientIP},
928 {"GetClientName", sm_GetClientName},
929 {"GetClientTeam", GetClientTeam},
930 {"GetClientUserId", GetClientUserId},
931 {"GetMaxClients", sm_GetMaxClients},
932 {"GetUserAdmin", GetUserAdmin},
933 {"GetUserFlagBits", GetUserFlagBits},
934 {"IsClientAuthorized", sm_IsClientAuthorized},
935 {"IsClientConnected", sm_IsClientConnected},
936 {"IsFakeClient", sm_IsClientFakeClient},
937 {"IsPlayerInGame", sm_IsClientInGame}, /* Backwards compat shim */
938 {"IsClientInGame", sm_IsClientInGame},
939 {"RemoveUserFlags", RemoveUserFlags},
940 {"SetUserAdmin", SetUserAdmin},
941 {"SetUserFlagBits", SetUserFlagBits},
942 {"GetClientDeaths", GetDeathCount},
943 {"GetClientFrags", GetFragCount},
944 {"GetClientArmor", GetArmorValue},
945 {"GetClientAbsOrigin", GetAbsOrigin},
946 {"GetClientAbsAngles", GetAbsAngles},
947 {"GetClientMins", GetPlayerMins},
948 {"GetClientMaxs", GetPlayerMaxs},
949 {"GetClientWeapon", GetWeaponName},
950 {"GetClientModel", GetModelName},
951 {"GetClientHealth", GetHealth},
952 {"GetClientTime", GetTimeConnected},
953 {"GetClientDataRate", GetDataRate},
954 {"IsClentTimingOut", IsTimingOut},
955 {"GetClientLatency", GetLatency},
956 {"GetClientAvgLatency", GetAvgLatency},
957 {"GetClientAvgLoss", GetAvgLoss},
958 {"GetClientAvgChoke", GetAvgChoke},
959 {"GetClientAvgData", GetAvgData},
960 {"GetClientAvgPackets", GetAvgPackets},
961 {"GetClientOfUserId", GetClientOfUserId},
962 {"ShowActivity", ShowActivity},