Added amb<536> requested for using sm_kick without putting quotes around reason.
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 #ifndef _INCLUDE_SOURCEMOD_CONVARMANAGER_H_
16 #define _INCLUDE_SOURCEMOD_CONVARMANAGER_H_
18 #include "sm_globals.h"
19 #include "sourcemm_api.h"
22 #include <IPluginSys.h>
23 #include <IForwardSys.h>
24 #include <IHandleSys.h>
25 #include <IRootConsoleMenu.h>
27 using namespace SourceHook;
30 * Holds SourceMod-specific information about a convar
34 Handle_t handle; /**< Handle to convar */
35 bool sourceMod; /**< Determines whether or not convar was created by a SourceMod plugin */
36 IChangeableForward *pChangeForward; /**< Forward associated with convar */
37 FnChangeCallback origCallback; /**< The original callback function */
38 #if PLAPI_VERSION < 12
39 const char *name; /**< Name of convar */
44 * Holds information about a client convar query
48 QueryCvarCookie_t cookie; /**< Cookie that identifies query */
49 IPluginFunction *pCallback; /**< Function that will be called when query is finished */
50 cell_t value; /**< Optional value passed to query function */
55 public IHandleTypeDispatch,
56 public IPluginsListener,
57 public IRootConsoleCommand
62 public: // SMGlobalClass
63 void OnSourceModAllInitialized();
64 void OnSourceModShutdown();
65 void OnSourceModVSPReceived(IServerPluginCallbacks *iface);
66 public: // IHandleTypeDispatch
67 void OnHandleDestroy(HandleType_t type, void *object);
68 public: // IPluginsListener
69 void OnPluginUnloaded(IPlugin *plugin);
70 public: //IRootConsoleCommand
71 void OnRootConsoleCommand(const char *command, unsigned int argcount);
74 * Get the 'ConVar' handle type ID.
76 inline HandleType_t GetHandleType()
82 * Get the convar lookup trie.
84 inline Trie *GetConVarCache()
90 * Create a convar and return a handle to it.
92 Handle_t CreateConVar(IPluginContext *pContext, const char *name, const char *defaultVal,
93 const char *description, int flags, bool hasMin, float min, bool hasMax, float max);
96 * Searches for a convar and returns a handle to it
98 Handle_t FindConVar(const char* name);
101 * Add a function to call when the specified convar changes.
103 void HookConVarChange(ConVar *pConVar, IPluginFunction *pFunction);
106 * Remove a function from the forward that will be called when the specified convar changes.
108 void UnhookConVarChange(ConVar *pConVar, IPluginFunction *pFunction);
111 * Starts a query to find the value of a client convar.
113 QueryCvarCookie_t QueryClientConVar(edict_t *pPlayer, const char *name, IPluginFunction *pCallback,
116 #if PLAPI_VERSION >= 12
118 * Called when Metamod:Source is about to remove convar
120 void OnUnlinkConCommandBase(PluginId id, ConCommandBase *pCommand);
123 * Called when Metamod:Source has unloaded a plugin
125 void OnMetamodPluginUnloaded(PluginId id);
129 * Adds a convar to a plugin's list.
131 static void AddConVarToPluginList(IPluginContext *pContext, const ConVar *pConVar);
134 * Static callback that Valve's ConVar object executes when the convar's value changes.
136 static void OnConVarChanged(ConVar *pConVar, const char *oldValue);
139 * Callback for when StartQueryCvarValue() has finished.
141 void OnQueryCvarValueFinished(QueryCvarCookie_t cookie, edict_t *pPlayer, EQueryCvarValueStatus result,
142 const char *cvarName, const char *cvarValue);
144 HandleType_t m_ConVarType;
145 List<ConVarInfo *> m_ConVars;
146 List<ConVarQuery> m_ConVarQueries;
148 IServerPluginCallbacks *m_VSPIface;
149 bool m_CanQueryConVars;
150 #if PLAPI_VERSION < 12
155 extern ConVarManager g_ConVarManager;
157 #endif // _INCLUDE_SOURCEMOD_CONVARMANAGER_H_