3 * ================================================================
5 * Copyright (C) 2004-2007 AlliedModders LLC. All rights reserved.
6 * ================================================================
8 * This program is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU General Public License,
10 * version 3.0, as published by the Free Software Foundation.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to
21 * link the code of this program (as well as its derivative works) to
22 * "Half-Life 2," the "Source Engine," the "SourcePawn JIT," and any
23 * Game MODs that run on software by the Valve Corporation. You must
24 * obey the GNU General Public License in all respects for all other
25 * code used. Additionally, AlliedModders LLC grants this exception
26 * to all derivative works. AlliedModders LLC defines further
27 * exceptions, found in LICENSE.txt (as of this writing, version
28 * JULY-31-2007), or <http://www.sourcemod.net/license.php>.
33 #ifndef _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
34 #define _INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_
36 #include "sm_globals.h"
38 #include "sourcemm_api.h"
39 #include <IForwardSys.h>
40 #include <IPlayerHelpers.h>
41 #include <IAdminSystem.h>
42 #include <sh_string.h>
44 #include <sh_vector.h>
46 using namespace SourceHook;
48 class CPlayer : public IGamePlayer
50 friend class PlayerManager;
54 const char *GetName();
55 const char *GetIPAddress();
56 const char *GetAuthString();
62 void SetAdminId(AdminId id, bool temporary);
64 void Kick(const char *str);
66 IPlayerInfo *GetPlayerInfo();
68 void Initialize(const char *name, const char *ip, edict_t *pEntity);
71 void SetName(const char *name);
72 void DumpAdmin(bool deleting);
73 void Authorize(const char *auth);
74 void Authorize_Post();
75 void DoBasicAdminChecks();
88 String m_LastPassword;
98 public: //SMGlobalClass
99 void OnSourceModAllInitialized();
100 void OnSourceModShutdown();
101 void OnSourceModLevelEnd();
102 ConfigResult OnSourceModConfigChanged(const char *key, const char *value, ConfigSource source, char *error, size_t maxlength);
104 CPlayer *GetPlayerByIndex(int client) const;
105 void RunAuthChecks();
106 void ClearAdminId(AdminId id);
107 void ClearAllAdmins();
109 bool OnClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
110 bool OnClientConnect_Post(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen);
111 void OnClientPutInServer(edict_t *pEntity, char const *playername);
112 void OnClientDisconnect(edict_t *pEntity);
113 void OnClientDisconnect_Post(edict_t *pEntity);
114 void OnClientCommand(edict_t *pEntity);
115 void OnClientSettingsChanged(edict_t *pEntity);
116 //void OnClientSettingsChanged_Pre(edict_t *pEntity);
117 public: //IPlayerManager
118 void AddClientListener(IClientListener *listener);
119 void RemoveClientListener(IClientListener *listener);
120 IGamePlayer *GetGamePlayer(int client);
121 IGamePlayer *GetGamePlayer(edict_t *pEdict);
124 int GetClientOfUserId(int userid);
126 inline int MaxClients()
130 inline int NumPlayers()
132 return m_PlayerCount;
134 bool CheckSetAdmin(int index, CPlayer *pPlayer, AdminId id);
135 bool CheckSetAdminName(int index, CPlayer *pPlayer, AdminId id);
136 const char *GetPassInfoVar();
137 void RecheckAnyAdmins();
139 void OnServerActivate(edict_t *pEdictList, int edictCount, int clientMax);
141 List<IClientListener *> m_hooks;
142 IForward *m_clconnect;
143 IForward *m_cldisconnect;
144 IForward *m_cldisconnect_post;
145 IForward *m_clputinserver;
146 IForward *m_clcommand;
147 IForward *m_clinfochanged;
149 IForward *m_onActivate;
150 IForward *m_onActivate2;
156 unsigned int *m_AuthQueue;
157 String m_PassInfoVar;
160 extern PlayerManager g_Players;
161 extern bool g_OnMapStarted;
163 #endif //_INCLUDE_SOURCEMOD_CPLAYERMANAGER_H_