SourceMod SDK  1.7
ISourceMod.h
Go to the documentation of this file.
1 
32 #ifndef _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
33 #define _INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
34 
40 #include <IHandleSys.h>
41 #include <sp_vm_api.h>
42 #include <IDataPack.h>
43 #include <time.h>
44 
45 #define SMINTERFACE_SOURCEMOD_NAME "ISourceMod"
46 #define SMINTERFACE_SOURCEMOD_VERSION 13
47 
51 class KeyValues;
52 
53 namespace SourceMod
54 {
58  enum PathType
59  {
60  Path_None = 0,
61  Path_Game,
62  Path_SM,
63  Path_SM_Rel,
64  };
65 
71  typedef void (*GAME_FRAME_HOOK)(bool simulating);
72 
78  typedef void (*FRAMEACTION)(void *data);
79 
83  class ISourceMod : public SMInterface
84  {
85  public:
86  virtual const char *GetInterfaceName()
87  {
88  return SMINTERFACE_SOURCEMOD_NAME;
89  }
90  virtual unsigned int GetInterfaceVersion()
91  {
92  return SMINTERFACE_SOURCEMOD_VERSION;
93  }
94  public:
100  virtual const char *GetGamePath() const =0;
101 
107  virtual const char *GetSourceModPath() const =0;
108 
128  virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format, ...) =0;
129 
137  virtual void LogMessage(IExtension *pExt, const char *format, ...) =0;
138 
146  virtual void LogError(IExtension *pExt, const char *format, ...) =0;
147 
159  virtual size_t FormatString(char *buffer,
160  size_t maxlength,
161  SourcePawn::IPluginContext *pContext,
162  const cell_t *params,
163  unsigned int param) =0;
164 
170  virtual IDataPack *CreateDataPack() =0;
171 
177  virtual void FreeDataPack(IDataPack *pack) =0;
178 
185  virtual HandleType_t GetDataPackHandleType(bool readonly=false) =0;
186 
196  virtual KeyValues *ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false) =0;
197 
203  virtual const char *GetGameFolderName() const =0;
204 
210  virtual SourcePawn::ISourcePawnEngine *GetScriptingEngine() =0;
211 
217  virtual SourcePawn::IVirtualMachine *GetScriptingVM() =0;
218 
224  virtual time_t GetAdjustedTime() =0;
225 
234  virtual unsigned int SetGlobalTarget(unsigned int index) =0;
235 
243  virtual unsigned int GetGlobalTarget() const =0;
244 
250  virtual void AddGameFrameHook(GAME_FRAME_HOOK hook) =0;
251 
257  virtual void RemoveGameFrameHook(GAME_FRAME_HOOK hook) =0;
258 
268  virtual size_t Format(char *buffer, size_t maxlength, const char *fmt, ...) = 0;
269 
279  virtual size_t FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap) = 0;
280 
289  virtual void AddFrameAction(FRAMEACTION fn, void *data) = 0;
290 
298  virtual const char *GetCoreConfigValue(const char *key) = 0;
299 
305  virtual int GetPluginId() = 0;
306 
307 
313  virtual int GetShApiVersion() = 0;
314 
320  virtual bool IsMapRunning() = 0;
321  };
322 }
323 
324 #endif //_INCLUDE_SOURCEMOD_MAIN_HELPER_INTERFACE_H_
virtual const char * GetSourceModPath() const =0
Returns the full path to the SourceMod directory.
virtual time_t GetAdjustedTime()=0
Returns the adjusted server time.
Defines the interface for creating, reading, and removing Handles.
virtual int GetPluginId()=0
Returns SourceMod's Metamod:Source plugin ID.
virtual HandleType_t GetDataPackHandleType(bool readonly=false)=0
Not implemented, do not use.
virtual unsigned int GetInterfaceVersion()
Must return an integer defining the interface's version.
Definition: ISourceMod.h:90
virtual IDataPack * CreateDataPack()=0
Creates a data pack object.
virtual void AddFrameAction(FRAMEACTION fn, void *data)=0
Adds an action to be executed on the next available frame.
virtual void LogMessage(IExtension *pExt, const char *format,...)=0
Logs a message to the SourceMod logs.
virtual void RemoveGameFrameHook(GAME_FRAME_HOOK hook)=0
Removes one game frame hook matching the given function.
virtual int GetShApiVersion()=0
Returns SourceHook's API version.
virtual void AddGameFrameHook(GAME_FRAME_HOOK hook)=0
Adds a function to be called each game frame.
virtual size_t FormatString(char *buffer, size_t maxlength, SourcePawn::IPluginContext *pContext, const cell_t *params, unsigned int param)=0
Formats a string from a native.
Defines the base functionality required by a shared interface.
Definition: IShareSys.h:92
virtual void FreeDataPack(IDataPack *pack)=0
Releases a data pack's resources so it can be re-used.
Contains miscellaneous helper functions.
Definition: ISourceMod.h:83
virtual const char * GetGameFolderName() const =0
Returns the name of the game directory.
virtual KeyValues * ReadKeyValuesHandle(Handle_t hndl, HandleError *err=NULL, bool root=false)=0
Retrieves a KeyValues pointer from a handle.
virtual unsigned int GetGlobalTarget() const =0
Returns the global client SourceMod is currently using for assisted translations (that is...
Specifies a data pack that can only be written.
Definition: IDataPack.h:128
virtual unsigned int SetGlobalTarget(unsigned int index)=0
Sets the global client SourceMod will use for assisted translations (that is, t). ...
Definition: IAdminSystem.h:63
virtual size_t FormatArgs(char *buffer, size_t maxlength, const char *fmt, va_list ap)=0
Platform-safe wrapper around vsnprintf().
virtual SourcePawn::IVirtualMachine * GetScriptingVM()=0
Deprecated, do not use.
virtual SourcePawn::ISourcePawnEngine * GetScriptingEngine()=0
Returns the scripting engine interface.
virtual const char * GetGamePath() const =0
Returns the full path to the game directory.
Contains functions for packing data abstractly to/from plugins. The wrappers for creating these are c...
Encapsulates an IExtensionInterface and its dependencies.
Definition: IExtensionSys.h:53
virtual size_t BuildPath(PathType type, char *buffer, size_t maxlength, const char *format,...)=0
Builds a platform path for a specific target base path.
virtual const char * GetInterfaceName()
Must return a string defining the interface's unique name.
Definition: ISourceMod.h:86
virtual bool IsMapRunning()=0
Returns whether or not a map is currently running.
virtual const char * GetCoreConfigValue(const char *key)=0
Retrieves a core.cfg configuration value.
virtual size_t Format(char *buffer, size_t maxlength, const char *fmt,...)=0
Platform-safe wrapper around snprintf().
virtual void LogError(IExtension *pExt, const char *format,...)=0
Logs a message to the SourceMod error logs.