-
Notifications
You must be signed in to change notification settings - Fork 23
Server API
The server exposes an interface (for Metamod or via AMXX module) to request additional information about the game or connected players.
C++ header and AMXX include are well-documented and can be found here (C++) or here (AMXX).
To use the API in your Metamod module you need to do the following:
- Copy the following files to your module's sources directory:
src/game/shared/ClientSupportsFlags.h
src/game/shared/enum_utils.h
src/game/shared/IBugfixedServer.h
src/game/shared/IGameVersion.h
src/bugfixedapi_amxx/bhl_api.cpp
src/bugfixedapi_amxx/bhl_api.h
optional:
src/game/shared/CGameVersion.cpp
src/game/shared/CGameVersion.h
- Check if you already have interface.h and interface.cpp. If not, get them from src/public/vinterface/.
- Include bhl_api.h in the main file of your module.
- Call
bhl::InitServerApi()
from module init function.InitServerApi
returnsE_ApiInitResult
. Check bhl_api.h for details. You can find an implementation in src/bugfixedapi_amxx/bugfixedapi_amxx.cpp inOnAmxxAttach
.
Warning! Some methods in the interface return a pointer to
IGameVersion
. You are not allowed to keep this pointer, it is only guaranteed to be valid immediately after calling (until control returns to the engine and server library). Instead you should make a copy of it usingCGameVersion
.
Warning! The API is not thread-safe. Please, only call it from the main engine thread.
The API can be used using bhl::serverapi()
function which returns a pointer to IBugfixedServer
.
- Copy bugfixedapi.inc from gamedir/addons/amxmodx/scripting/include/bugfixedapi.inc to addons/amxmodx/scripting/include.
- Include bugfixedapi.inc in your plugin.
- Check the include source code for documentation.
- General
- Client
- Server