3 * =============================================================================
4 * SourceMod Counter-Strike:Source Extension
5 * Copyright (C) 2004-2008 AlliedModders LLC. All rights reserved.
6 * =============================================================================
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU General Public License, version 3.0, as published by the
10 * Free Software Foundation.
12 * This program is distributed in the hope that it will be useful, but WITHOUT
13 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
14 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
17 * You should have received a copy of the GNU General Public License along with
18 * this program. If not, see <http://www.gnu.org/licenses/>.
20 * As a special exception, AlliedModders LLC gives you permission to link the
21 * code of this program (as well as its derivative works) to "Half-Life 2," the
22 * "Source Engine," the "SourcePawn JIT," and any Game MODs that run on software
23 * by the Valve Corporation. You must obey the GNU General Public License in
24 * all respects for all other code used. Additionally, AlliedModders LLC grants
25 * this exception to all derivative works. AlliedModders LLC defines further
26 * exceptions, found in LICENSE.txt (as of this writing, version JULY-31-2007),
27 * or <http://www.sourcemod.net/license.php>.
32 #ifndef _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
33 #define _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_
37 * @brief Sample extension code header.
40 #include "smsdk_ext.h"
41 #include "CDetour/detours.h"
42 #include <IBinTools.h>
43 #include <ISDKTools.h>
45 int CallPriceForward(int client, const char *weapon_name, int price);
47 #if SOURCE_ENGINE == SE_CSGO
49 #define WEAPON_KNIFE 42
50 #define WEAPON_KNIFE_GG 41
51 #define WEAPON_KEVLAR 50
52 #define WEAPON_ASSAULTSUIT 51
53 #define WEAPON_NIGHTVISION 52
54 #define WEAPON_DEFUSER 53
57 #define WEAPON_KNIFE 28
58 #define WEAPON_SHIELD 30
59 #define WEAPON_KEVLAR 31
60 #define WEAPON_ASSAULTSUIT 32
61 #define WEAPON_NIGHTVISION 33
65 * @brief Sample implementation of the SDK Extension.
66 * Note: Uncomment one of the pre-defined virtual functions in order to use it.
70 public ICommandTargetProcessor,
71 public IPluginsListener
75 * @brief This is called after the initial loading sequence has been processed.
77 * @param error Error message buffer.
78 * @param maxlength Size of error message buffer.
79 * @param late Whether or not the module was loaded after map load.
80 * @return True to succeed loading, false to fail.
82 virtual bool SDK_OnLoad(char *error, size_t maxlength, bool late);
85 * @brief This is called right before the extension is unloaded.
87 virtual void SDK_OnUnload();
90 * @brief This is called once all known extensions have been loaded.
91 * Note: It is is a good idea to add natives here, if any are provided.
93 virtual void SDK_OnAllLoaded();
96 * @brief Called when the pause state is changed.
98 //virtual void SDK_OnPauseChange(bool paused);
101 * @brief this is called when Core wants to know if your extension is working.
103 * @param error Error message buffer.
104 * @param maxlength Size of error message buffer.
105 * @return True if working, false otherwise.
107 virtual bool QueryRunning(char *error, size_t maxlength);
109 void NotifyInterfaceDrop(SMInterface *pInterface);
110 bool QueryInterfaceDrop(SMInterface *pInterface);
112 const char *GetExtensionVerString();
113 const char *GetExtensionDateString();
115 bool ProcessCommandTarget(cmd_target_info_t *info);
116 public: //IPluginsListener
117 void OnPluginLoaded(IPlugin *plugin);
118 void OnPluginUnloaded(IPlugin *plugin);
120 #if defined SMEXT_CONF_METAMOD
122 * @brief Called when Metamod is attached, before the extension version is called.
124 * @param error Error buffer.
125 * @param maxlength Maximum size of error buffer.
126 * @param late Whether or not Metamod considers this a late load.
127 * @return True to succeed, false to fail.
129 virtual bool SDK_OnMetamodLoad(ISmmAPI *ismm, char *error, size_t maxlength, bool late);
132 * @brief Called when Metamod is detaching, after the extension version is called.
133 * NOTE: By default this is blocked unless sent from SourceMod.
135 * @param error Error buffer.
136 * @param maxlength Maximum size of error buffer.
137 * @return True to succeed, false to fail.
139 //virtual bool SDK_OnMetamodUnload(char *error, size_t maxlength);
142 * @brief Called when Metamod's pause state is changing.
143 * NOTE: By default this is blocked unless sent from SourceMod.
145 * @param paused Pause state being set.
146 * @param error Error buffer.
147 * @param maxlength Maximum size of error buffer.
148 * @return True to succeed, false to fail.
150 //virtual bool SDK_OnMetamodPauseChange(bool paused, char *error, size_t maxlength);
153 bool m_WeaponPriceDetourEnabled;
154 bool m_TerminateRoundDetourEnabled;
155 bool m_HandleBuyDetourEnabled;
156 bool m_CSWeaponDetourEnabled;
159 /* Interfaces from SourceMod */
160 extern IBinTools *g_pBinTools;
161 extern IGameConfig *g_pGameConf;
162 extern ISDKTools *g_pSDKTools;
163 extern int g_msgHintText;
164 extern bool g_pIgnoreTerminateDetour;
165 extern bool g_pIgnoreCSWeaponDropDetour;
166 extern bool g_pTerminateRoundDetoured;
167 extern bool g_pCSWeaponDropDetoured;
168 extern int weaponNameOffset;
170 #endif // _INCLUDE_SOURCEMOD_EXTENSION_PROPER_H_