Scripting with AMX Mod X
YaPB ships a native AMX Mod X module (yapb_amxx) that exposes the bot core to Pawn plugins through yapb.inc. You can inspect bots, move them around the graph, freeze them, read their state, intercept chat, and react to spawn/kill/remove events.
Source files live in the bot repo and are also shipped inside every release archive under cfg/:
- Module source:
ext/amxx/yapb_amxx.cpp(ext/amxx/yapb_amxx.h,ext/amxx/CMakeLists.txt) - Pawn include (generated, do not edit by hand):
cfg/addons/amxmodx/scripting/include/yapb.inc - Generator:
tools/gen_amxx_inc.py- runpython3 tools/gen_amxx_inc.py --checkin CI to make sureyapb.incis in sync - Bundled plugins:
cfg/addons/amxmodx/scripting/yapb_takeover.sma,yapb_chat_ai.sma - Takeover translations:
cfg/addons/amxmodx/data/lang/yapb_takeover.txt
Requirements
Section titled “Requirements”| Component | Required | Notes |
|---|---|---|
| YaPB bot binary | Yes | The module loads addons/yapb/bin/yapb.dll / yapb.so at runtime. If it is missing, all natives become unavailable (they raise Native is unavailable. YaPB binary isn't loaded.). |
| AMX Mod X | 1.8.2+ (1.9/1.10 recommended) | Provides the Pawn runtime, amxmodx, amxmisc, cstrike includes. |
yapb_amxx module binary |
Yes | Ships in the release archive under addons/amxmodx/modules/: yapb_amxx.dll (Windows) / yapb_amxx_i386.so (Linux). 32-bit (i386) only, like the bot itself. Built with YAPB_WITH_AMXX=ON (default). |
| Compiler | amxxpc from AMX Mod X |
To build the bundled .sma files into .amxx. |
yapb.inc |
Yes | Copy cfg/addons/amxmodx/scripting/include/yapb.inc to your addons/amxmodx/scripting/include/ folder. Generated from ext/amxx/yapb_amxx.cpp + inc/module.h, inc/graph.h, inc/constant.h, inc/tasks.h. |
Plugin-specific extra dependencies are documented on the Bundled Plugins page. In short:
yapb_takeover.smaneeds ReAPI (and therefore ReHLDS/ReGameDLL), plusfakemetaandhamsandwich.yapb_chat_ai.smaneeds AmxxEasyHttp (easy_httpmodule +easy_http.inc/easy_http_json.inc) by Next21Team, and an OpenAI-compatiblePOST /v1/chat/completionsendpoint.
Installation
Section titled “Installation”-
Install YaPB itself first (see Installation). AMX Mod X setups should run the bot as a MetaMod plugin.
-
Check that the release archive already placed the module here:
cstrike/addons/amxmodx/modules/yapb_amxx.dllcstrike/addons/amxmodx/modules/yapb_amxx_i386.soIf you build from source, copy the built file from
build/.../ext/amxx/there yourself. -
Enable the module in
cstrike/addons/amxmodx/configs/modules.ini:yapb_amxxOn Linux AMXX resolves it to
yapb_amxx_i386.soautomatically. -
Copy
yapb.inctocstrike/addons/amxmodx/scripting/include/yapb.inc. -
Compile the plugins you need with
amxxpcand put the resulting.amxxfiles intocstrike/addons/amxmodx/plugins/, then list them incstrike/addons/amxmodx/configs/plugins.ini:yapb_takeover.amxxyapb_chat_ai.amxx -
Restart the map (or the server) and verify:
amxx modulesamxx pluginsmeta listamxx modulesmust show theYaPB APImodule as running. If it reports an error, check the AMXX logs - the module logs why it could not find or open the YaPB binary.
Directorycstrike/
Directoryaddons/
Directoryamxmodx/
Directoryconfigs/
- modules.ini # add
yapb_amxxhere - plugins.ini # add
yapb_takeover.amxx,yapb_chat_ai.amxxhere
- modules.ini # add
Directorymodules/
- yapb_amxx.dll # Windows (shipped)
- yapb_amxx_i386.so # Linux (shipped)
- easy_http.dll / easy_http_i386.so # only for Chat AI
Directoryplugins/
- yapb_takeover.amxx # compiled by you
- yapb_chat_ai.amxx # compiled by you
Directoryscripting/
Directoryinclude/
- yapb.inc # shipped source, copy here
- easy_http.inc # only for Chat AI
Directorydata/
Directorylang/
- yapb_takeover.txt # shipped, copy here
Directoryyapb/
Directorybin/
- yapb.dll / yapb.so # loaded by yapb_amxx at runtime
Quick start
Section titled “Quick start”#include <amxmodx>#include <yapb>
public plugin_init (){ register_plugin ("My YaPB Plugin", "1.0", "me");}
public yb_bot_spawned (index){ new version[32]; yb_get_bot_version (version, charsmax (version));
server_print ("bot %d spawned, running %s (api %d)", index, version, yb_get_api_version ());}yapb.inc declares #pragma reqlib yapb (+ #pragma loadlib yapb unless AMXMODX_NOAUTOLOAD is defined), so the plugin refuses to run without the module.
API versioning
Section titled “API versioning”The module API is versioned as major << 16 | minor (see kBotModuleApiMajor / kBotModuleApiMinor in inc/module.h, currently 3.6).
yb_get_api_version()returns the packed version, or0when the bot is not loaded.yb_api_at_least(major, minor)is a stock helper inyapb.inc- use it to gate features:
public plugin_init (){ register_plugin ("My YaPB Plugin", "1.0", "me");
if (!yb_api_at_least (3, 2)) { set_fail_state ("YaPB API 3.2 or newer is required"); }}The bundled Takeover plugin, for example, requires API 3.2+ because it uses yb_set_bot_simulation() / yb_is_bot_simulating().
How it works
Section titled “How it works”ext/amxx/yapb_amxx.cpp implements the thin AMXX_Query / AMXX_Attach / AMXX_PluginsLoaded / AMXX_Detach entry points, binds the AMXX core functions (AddNatives, GetAmxAddr, GetAmxString, RegisterForward, …), then dlopens the bot binary, resolves the GetBotAPI export and forwards every native to IBotModule / IBotChatAPI from inc/module.h. Bot events (Spawned, Killed, Removed, ChatPre, ChatPost) are re-emitted as AMXX forwards (yb_bot_spawned, yb_bot_killed, yb_bot_removed, yb_chat_pre, yb_chat_post).
yapb_amxx.h is intentionally self-contained (no AMXX SDK headers) - it defines the minimal AMX, AMX_NATIVE_INFO, and module ABI itself.