2 * ===============================================================
3 * SourceMod (C)2004-2007 AlliedModders LLC. All rights reserved.
4 * ===============================================================
6 * This file is not open source and may not be copied without explicit
7 * written permission of AlliedModders LLC. This file may not be redistributed
8 * in whole or significant part.
9 * For information, see LICENSE.txt or http://www.sourcemod.net/license.php
14 #ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
15 #define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
17 #include "sm_globals.h"
19 #include "sourcemm_api.h"
20 #include <IForwardSys.h>
21 #include <IPlayerHelpers.h>
22 #include <IAdminSystem.h>
23 #include <sh_string.h>
25 #include <sh_vector.h>
27 using namespace SourceHook;
29 class CPlayer : public IGamePlayer
31 friend class CPlayerManager;
35 const char *GetName() const;
36 const char *GetIPAddress() const;
37 const char *GetAuthString() const;
38 edict_t *GetEdict() const;
39 bool IsInGame() const;
40 bool IsConnected() const;
41 bool IsAuthorized() const;
42 bool IsFakeClient() const;
43 void SetAdminId(AdminId id, bool temporary);
44 AdminId GetAdminId() const;
46 void Initialize(const char *name, const char *ip, edict_t *pEntity);
48 void Authorize(const char *steamid);
50 void SetName(const char *name);
51 void DumpAdmin(bool deleting);
64 class CPlayerManager :
71 public: //SMGlobalClass
72 void OnSourceModAllInitialized();
73 void OnSourceModShutdown();
75 CPlayer *GetPlayerByIndex(int client) const;
77 void ClearAdminId(AdminId id);
78 void ClearAllAdmins();
80 bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
81 bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
82 void OnClientPutInServer(edict_t *pEntity, char const *playername);
83 void OnClientDisconnect(edict_t *pEntity);
84 void OnClientDisconnect_Post(edict_t *pEntity);
85 void OnClientCommand(edict_t *pEntity);
86 void OnClientSettingsChanged(edict_t *pEntity);
87 public: //IPlayerManager
88 void AddClientListener(IClientListener *listener);
89 void RemoveClientListener(IClientListener *listener);
90 IGamePlayer *GetGamePlayer(int client);
91 IGamePlayer *GetGamePlayer(edict_t *pEdict);
95 inline int MaxClients()
99 inline int NumPlayers()
101 return m_PlayerCount;
104 void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
106 List<IClientListener *> m_hooks;
107 IForward *m_clconnect;
108 IForward *m_cldisconnect;
109 IForward *m_cldisconnect_post;
110 IForward *m_clputinserver;
111 IForward *m_clcommand;
112 IForward *m_clinfochanged;
118 unsigned int *m_AuthQueue;
121 extern CPlayerManager g_Players;
123 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_