1 #include "CPlayerManager.h"
3 //:TODO: register these and use the same capitalization conventions as the natives
5 static cell_t sm_getclientcount(IPluginContext *pCtx, const cell_t *params)
9 return g_PlayerManager.GetPlayerCount();
12 int maxplayers = g_PlayerManager.GetMaxClients();
14 for (int i=1; i<=maxplayers; ++i)
16 CPlayer *pPlayer = g_PlayerManager.GetPlayerByIndex(i);
17 if ((pPlayer->IsPlayerConnected()) && !(pPlayer->IsPlayerInGame()))
23 return (g_PlayerManager.GetPlayerCount() + count);
26 static cell_t sm_getmaxclients(IPluginContext *pCtx, const cell_t *params)
28 return g_PlayerManager.GetMaxClients();
31 static cell_t sm_getclientname(IPluginContext *pCtx, const cell_t *params)
33 int index = params[1];
34 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
36 //:TODO: runtime error
39 pCtx->StringToLocalUTF8(params[2], static_cast<size_t>(params[3]), g_PlayerManager.GetPlayerByIndex(index)->PlayerName(), NULL);
43 static cell_t sm_getclientip(IPluginContext *pCtx, const cell_t *params)
45 int index = params[1];
46 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
48 //:TODO: runtime error
51 pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), g_PlayerManager.GetPlayerByIndex(index)->PlayerIP());
55 static cell_t sm_getclientauthstr(IPluginContext *pCtx, const cell_t *params)
57 int index = params[1];
58 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
60 //:TODO: runtime error
63 pCtx->StringToLocal(params[2], static_cast<size_t>(params[3]), g_PlayerManager.GetPlayerByIndex(index)->PlayerAuthString());
67 static cell_t sm_isplayerconnected(IPluginContext *pCtx, const cell_t *params)
69 int index = params[1];
70 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
72 //:TODO: runtime error
75 return (g_PlayerManager.GetPlayerByIndex(index)->IsPlayerConnected()) ? 1 : 0;
78 static cell_t sm_isplayeringame(IPluginContext *pCtx, const cell_t *params)
80 int index = params[1];
81 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
83 //:TODO: runtime error
86 return (g_PlayerManager.GetPlayerByIndex(index)->IsPlayerInGame()) ? 1 : 0;
89 static cell_t sm_isplayerauthorized(IPluginContext *pCtx, const cell_t *params)
91 int index = params[1];
92 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
94 //:TODO: runtime error
97 return (g_PlayerManager.GetPlayerByIndex(index)->IsPlayerAuthorized()) ? 1 : 0;
100 static cell_t sm_isplayerfakeclient(IPluginContext *pCtx, const cell_t *params)
102 int index = params[1];
103 if ((index < 1) || (index > g_PlayerManager.GetMaxClients()))
105 //:TODO: runtime error
108 return (g_PlayerManager.GetPlayerByIndex(index)->IsPlayerFakeClient()) ? 1 : 0;