Enum Structs1
SymbolDescription
PluginPlugin public information.
Method Maps3
Enumerations4
SymbolDescription
APLRes
FeatureStatusFeature statuses.
FeatureTypeFeature types.
NumberTypeRepresents how many bytes we can read from an address with one load
Type Definitions1
SymbolDescription
Address
Defines3
SymbolDescription
MAPLIST_FLAG_CLEARARRAYIf an input array is specified, clear it before adding.
MAPLIST_FLAG_MAPSFOLDEROn failure, use all maps in the maps folder.
MAPLIST_FLAG_NO_DEFAULTDo not read "default" or "mapcyclefile" on failure.
Forwards18
SymbolDescription
AskPluginLoad
AskPluginLoad2Called before OnPluginStart, in case the plugin wants to check for load failure. This is called even if the plugin type is "private." Any natives from modules are not available at this point. Thus, this forward should only be used for explicit pre-emptive things, such as adding dynamic natives, setting certain types of load filters (such as not loading the plugin for certain games).
OnAllPluginsLoadedCalled after all plugins have been loaded. This is called once for every plugin. If a plugin late loads, it will be called immediately after OnPluginStart().
OnAutoConfigsBufferedThis is called once, right after OnMapStart() but any time before OnConfigsExecuted(). It is called after the "exec sourcemod.cfg" command and all AutoExecConfig() exec commands have been added to the ServerCommand() buffer. If you need to load per-map settings that override default values, adding commands to the ServerCommand() buffer here will guarantee that they're set before OnConfigsExecuted(). Unlike OnMapStart() and OnConfigsExecuted(), this is not called on late loads that occur after OnMapStart().
OnClientFloodCheckCalled when a client has sent chat text. This must return either true or false to indicate that a client is or is not spamming the server. The return value is a hint only. Core or another plugin may decide otherwise.
OnClientFloodResultCalled after a client's flood check has been computed. This can be used by antiflood algorithms to decay/increase flooding weights. Since the result from "OnClientFloodCheck" isn't guaranteed to be the final result, it is generally a good idea to use this to play with other algorithms nicely.
OnConfigsExecutedCalled when the map has loaded, servercfgfile (server.cfg) has been executed, and all plugin configs are done executing. This is the best place to initialize plugin functions which are based on cvar data.
OnGameFrameCalled before every server frame. Note that you should avoid doing expensive computations or declaring large local arrays.
OnLibraryAddedCalled after a library is added. A library is either a plugin name or extension name, as exposed via its include file.
OnLibraryRemovedCalled right before a library is removed. A library is either a plugin name or extension name, as exposed via its include file.
OnMapEndCalled right before a map ends.
OnMapInitCalled when the map starts loading.
OnMapStartCalled when the map is loaded.
OnNotifyPluginUnloadedCalled when a plugin unloaded.
OnPluginEndCalled when the plugin is about to be unloaded. It is not necessary to close any handles or remove hooks in this function. SourceMod guarantees that plugin shutdown automatically and correctly releases all resources.
OnPluginPauseChangeCalled when the plugin's pause status is changing.
OnPluginStartCalled when the plugin is fully initialized and all known external references are resolved. This is only called once in the lifetime of the plugin, and is paired with OnPluginEnd(). If any run-time error is thrown during this callback, the plugin will be marked as failed.
OnServerCfg
Functions33
SymbolDescription
AutoExecConfigSpecifies that the given config file should be executed after plugin load. OnConfigsExecuted() will not be called until the config file has executed, but it will be called if the execution fails.
CanTestFeaturesReturns whether "GetFeatureStatus" will work. Using this native or this function will not cause SourceMod to fail loading on older versions, however, GetFeatureStatus will only work if this function returns true.
FindPluginByNumberFinds a plugin by its order in the list from the "plugins list" server "sm" command. You should not use this function to loop through all plugins, use the iterator instead. Looping through all plugins using this native is O(n^2), whereas using the iterator is O(n).
FormatTimeProduces a date and/or time string value for a timestamp. See this URL for valid parameters: https://cplusplus.com/reference/ctime/strftime/ Note that available parameters depends on support from your operating system. In particular, ones highlighted in yellow on that page are not currently available on Windows and should be avoided for portable plugins.
GameConfGetAddressFinds an address calculation in a GameConfig file, performs LoadFromAddress on it as appropriate, then returns the final address.
GameConfGetKeyValueGets the value of a key from the "Keys" section.
GameConfGetOffsetReturns an offset value.
GetExtensionFileStatusReturns the status of an extension, by filename.
GetFeatureStatusReturns whether a feature exists, and if so, whether it is usable.
GetMyHandleReturns the calling plugin's Handle.
GetPluginFilenameRetrieves a plugin's file name relative to the plugins folder.
GetPluginInfoRetrieves a plugin's public info.
GetPluginIteratorReturns an iterator that can be used to search through plugins.
GetPluginStatusReturns a plugin's status.
GetSysTickCountReturns the operating system's "tick count," which is a number of milliseconds since the operating system loaded. This can be used for basic benchmarks.
GetTimeGets the system time as a unix timestamp.
IsPluginDebuggingRetrieves whether or not a plugin is being debugged.
LibraryExistsReturns whether a library exists. This function should be considered expensive; it should only be called on plugin to determine availability of resources. Use OnLibraryAdded()/OnLibraryRemoved() to detect changes in libraries.
LoadAddressFromAddressLoad sizeof(void*) from a memory address.
LoadFromAddressLoad up to 4 bytes from a memory address.
LoadGameConfigFileLoads a game config file.
LogStackTraceLogs a stack trace from the current function call. Code execution continues after the call
MorePluginsReturns whether there are more plugins available in the iterator.
ParseTimeParses a string representing a date and/or time into a unix timestamp. The timezone is always interpreted as UTC/GMT. See this URL for valid parameters: https://en.cppreference.com/w/cpp/io/manip/get_time Note that available parameters depends on support from your operating system. In particular, ones highlighted in yellow on that page are not currently available on Windows and should be avoided for portable plugins.
ReadMapListLoads a map list to an ADT Array. A map list is a list of maps from a file. SourceMod allows easy configuration of maplists through addons/sourcemod/configs/maplists.cfg. Each entry is given a name and a file (for example, "rtv" => "rtv.cfg"), or a name and a redirection (for example, "rtv" => "default"). This native will read a map list entry, cache the file, and return the list of maps it holds. Serial change numbers are used to identify if a map list has changed. Thus, if you pass a serial change number and it's equal to what SourceMod currently knows about the map list, then SourceMod won't re-parse the file. If the maps end up being read from the maps folder (MAPLIST_FLAG_MAPSFOLDER), they are automatically sorted in alphabetical, ascending order. Arrays created by this function are temporary and must be freed via CloseHandle(). Modifying arrays created by this function will not affect future return values or or the contents of arrays returned to other plugins.
ReadPluginReturns the current plugin in the iterator and advances the iterator.
RegPluginLibraryRegisters a library name for identifying as a dependency to other plugins.
RequireFeatureRequires that a given feature is available. If it is not, SetFailState() is called with the given message.
SetFailStateCauses the plugin to enter a failed state. An error will be thrown and the plugin will be paused until it is unloaded or reloaded. For backwards compatibility, if no extra arguments are passed, no formatting is applied. If one or more additional arguments is passed, the string is formatted using Format(). If any errors are encountered during formatting, both the format specifier string and an additional error message are written. This function does not return, and no further code in the plugin is executed.
SetMapListCompatBindMakes a compatibility binding for map lists. For example, if a function previously used "clam.cfg" for map lists, this function will insert a "fake" binding to "clam.cfg" that will be overridden if it's in the maplists.cfg file.
StoreAddressToAddressStore sizeof(void*) bytes to a memory address.
StoreToAddressStore up to 4 bytes to a memory address.
ThrowErrorAborts the current callback and throws an error. This function does not return in that no code is executed following it.