AMXX API Reference
Current module API: 3.6 (kBotModuleApiMajor / kBotModuleApiMinor in inc/module.h). Check it at runtime with yb_get_api_version() / yb_api_at_least() (see Scripting).
Conventions below:
- Bot
indexis the player entity index (1..maxplayers). Always validate withyb_is_user_bot(). - Node indexes are graph indexes, or
YB_INVALID_NODE_INDEX(-1) when none. - Entity indexes use
YB_INVALID_ENTITY_INDEX(0) when none. Float:origin[3]params are world coordinates.
YBNodeFlag
Section titled “YBNodeFlag”Bit flags returned by yb_get_node_flags().
| Value | Meaning |
|---|---|
YB_NODE_FLAG_BUTTON (1<<0) |
Button nearby |
YB_NODE_FLAG_LIFT (1<<1) |
Lift / elevator |
YB_NODE_FLAG_CROUCH (1<<2) |
Crouch point |
YB_NODE_FLAG_CROSSING (1<<3) |
Crossing |
YB_NODE_FLAG_GOAL (1<<4) |
Goal point |
YB_NODE_FLAG_LADDER (1<<5) |
Ladder |
YB_NODE_FLAG_RESCUE (1<<6) |
Hostage rescue zone |
YB_NODE_FLAG_CAMP (1<<7) |
Camp point |
YB_NODE_FLAG_NO_HOSTAGE (1<<8) |
Hostages avoid this node |
YB_NODE_FLAG_DOUBLE_JUMP (1<<9) |
Double-jump assist spot |
YB_NODE_FLAG_NARROW (1<<10) |
Narrow passage |
YB_NODE_FLAG_SNIPER (1<<28) |
Sniper spot |
YB_NODE_FLAG_TERRORIST_ONLY (1<<29) |
Terrorists only |
YB_NODE_FLAG_CT_ONLY (1<<30) |
Counter-Terrorists only |
YBNodeType
Section titled “YBNodeType”Used by yb_get_random_node().
| Value | Meaning |
|---|---|
YB_NODE_TYPE_TERRORIST 0 |
Terrorist spawn-ish |
YB_NODE_TYPE_CT 1 |
CT spawn-ish |
YB_NODE_TYPE_GOAL 2 |
Goal |
YB_NODE_TYPE_CAMP 3 |
Camp |
YB_NODE_TYPE_SNIPER 4 |
Sniper |
YB_NODE_TYPE_RESCUE 5 |
Rescue |
YBDifficulty
Section titled “YBDifficulty”| Value | Meaning |
|---|---|
YB_DIFFICULTY_NOOB 0 |
Newbie |
YB_DIFFICULTY_EASY 1 |
Average |
YB_DIFFICULTY_NORMAL 2 |
Normal |
YB_DIFFICULTY_HARD 3 |
Professional |
YB_DIFFICULTY_EXPERT 4 |
Godlike |
YBPersonality
Section titled “YBPersonality”| Value | Meaning |
|---|---|
YB_PERSONALITY_NORMAL 0 |
Normal |
YB_PERSONALITY_RUSHER 1 |
Aggressive / rusher |
YB_PERSONALITY_CAREFUL 2 |
Careful |
YBTask
Section titled “YBTask”Current bot task from yb_get_bot_task().
| Value | Meaning |
|---|---|
YB_TASK_NORMAL 0 |
Normal |
YB_TASK_PAUSE 1 |
Pause |
YB_TASK_MOVE_TO 2 |
Move to |
YB_TASK_FOLLOW_USER 3 |
Follow user |
YB_TASK_PICKUP_ITEM 4 |
Pickup item |
YB_TASK_CAMP 5 |
Camp |
YB_TASK_PLANT_BOMB 6 |
Plant bomb |
YB_TASK_DEFUSE_BOMB 7 |
Defuse bomb |
YB_TASK_ATTACK 8 |
Attack |
YB_TASK_HUNT 9 |
Hunt |
YB_TASK_SEEK_COVER 10 |
Seek cover |
YB_TASK_THROW_EXPLOSIVE 11 |
Throw HE |
YB_TASK_THROW_FLASHBANG 12 |
Throw flashbang |
YB_TASK_THROW_SMOKE 13 |
Throw smoke |
YB_TASK_DOUBLE_JUMP 14 |
Double jump |
YB_TASK_ESCAPE_FROM_BOMB 15 |
Escape from bomb |
YB_TASK_SHOOT_BREAKABLE 16 |
Shoot breakable |
YB_TASK_HIDE 17 |
Hide |
YB_TASK_BLIND 18 |
Blind |
YB_TASK_SPRAYPAINT 19 |
Spraypaint |
YB_TASK_NONE 20 |
None |
YBChatMode
Section titled “YBChatMode”Who may chat for a bot (yb_set_bot_chat() / yb_get_bot_chat()).
| Value | Meaning |
|---|---|
YB_CHAT_INVALID -1 |
Invalid bot |
YB_CHAT_AUTO 0 |
Core AI decides when and what to say |
YB_CHAT_MANUAL 1 |
Core AI is silent, plugin controls all chat |
YB_CHAT_OFF 2 |
No chat at all |
YBChatSource
Section titled “YBChatSource”Who produced a chat message in yb_chat_pre / yb_chat_post.
| Value | Meaning |
|---|---|
YB_CHAT_HUMAN 0 |
Human player |
YB_CHAT_BOT 1 |
Bot (core AI) |
YB_CHAT_PLUGIN 2 |
Plugin (via yb_bot_say()) |
Sentinel constants
Section titled “Sentinel constants”enum { YB_INVALID_NODE_INDEX = -1, YB_INVALID_ENTITY_INDEX = 0};Helper stock
Section titled “Helper stock”stock bool:yb_api_at_least (const major, const minor)Returns true when the loaded module API is at least major.minor. Decode manually if needed: major = version >>> 16, minor = version & 0xFFFF.
General
Section titled “General”yb_get_api_version()
Section titled “yb_get_api_version()”native yb_get_api_version ();Gets the bot API version, packed as major << 16 | minor. Returns 0 if the bot is not loaded.
yb_get_bot_version(output[], len)
Section titled “yb_get_bot_version(output[], len)”native yb_get_bot_version (output[], len);Copies the bot version string into output. Returns number of characters copied.
yb_game_has_bots()
Section titled “yb_game_has_bots()”native bool:yb_game_has_bots ();Returns true when bots are in game.
yb_get_bot_count()
Section titled “yb_get_bot_count()”native yb_get_bot_count ();Number of bots currently in game.
yb_add_bot()
Section titled “yb_add_bot()”native bool:yb_add_bot (YBDifficulty:difficulty = YBDifficulty:YB_DIFFICULTY_NORMAL, YBPersonality:personality = YBPersonality:YB_PERSONALITY_NORMAL, CsTeams:team = CS_TEAM_UNASSIGNED);Queues a bot add. Returns 1 when the request was queued. Needs <cstrike> for CsTeams.
yb_is_user_bot(index)
Section titled “yb_is_user_bot(index)”native bool:yb_is_user_bot (index);Returns true when index is a YaPB bot.
yb_kick_bot(index, silent = true, reduce_quota = true)
Section titled “yb_kick_bot(index, silent = true, reduce_quota = true)”native bool:yb_kick_bot (index, bool:silent = true, bool:reduce_quota = true);Kicks a single bot. Returns 1 on success.
yb_get_quota() / yb_set_quota(count)
Section titled “yb_get_quota() / yb_set_quota(count)”native yb_get_quota ();native bool:yb_set_quota (count);Read / write the bot quota (yb_quota). yb_set_quota() returns 1 on success, 0 when the bot is not loaded.
Bot state
Section titled “Bot state”yb_get_bot_origin(index, Float:origin[3])
Section titled “yb_get_bot_origin(index, Float:origin[3])”native bool:yb_get_bot_origin (index, Float:origin[3]);Stores the bot origin. Returns 1 on success.
yb_get_bot_weapon(index)
Section titled “yb_get_bot_weapon(index)”native yb_get_bot_weapon (index);Current weapon id (CSW_*), 0 when invalid.
yb_get_bot_weapon_name(index, output[], len)
Section titled “yb_get_bot_weapon_name(index, output[], len)”native bool:yb_get_bot_weapon_name (index, output[], len);Copies the current weapon classname. Returns 1 on success.
yb_get_bot_ammo(index, weapon) / yb_get_bot_ammo_in_clip(index)
Section titled “yb_get_bot_ammo(index, weapon) / yb_get_bot_ammo_in_clip(index)”native yb_get_bot_ammo (index, weapon);native yb_get_bot_ammo_in_clip (index);Total reserve ammo for weapon id, and ammo in the current clip.
yb_get_bot_ping(index)
Section titled “yb_get_bot_ping(index)”native yb_get_bot_ping (index);Bot ping (0 when invalid).
yb_get_bot_difficulty(index) / yb_set_bot_difficulty(index, YBDifficulty:difficulty)
Section titled “yb_get_bot_difficulty(index) / yb_set_bot_difficulty(index, YBDifficulty:difficulty)”native YBDifficulty:yb_get_bot_difficulty (index);native bool:yb_set_bot_difficulty (index, YBDifficulty:difficulty);Read / write bot difficulty (see YBDifficulty).
yb_get_bot_personality(index) / yb_set_bot_personality(index, YBPersonality:personality)
Section titled “yb_get_bot_personality(index) / yb_set_bot_personality(index, YBPersonality:personality)”native YBPersonality:yb_get_bot_personality (index);native bool:yb_set_bot_personality (index, YBPersonality:personality);Read / write bot personality (see YBPersonality).
yb_get_bot_task(index) / yb_get_bot_task_data(index)
Section titled “yb_get_bot_task(index) / yb_get_bot_task_data(index)”native YBTask:yb_get_bot_task (index);native yb_get_bot_task_data (index);Current task id (see YBTask) and its task data (usually a node index, YB_INVALID_NODE_INDEX when none).
yb_get_bot_node(index) / yb_get_bot_goal(index)
Section titled “yb_get_bot_node(index) / yb_get_bot_goal(index)”native yb_get_bot_node (index);native yb_get_bot_goal (index);Node the bot stands on (dead/camping bots report YB_INVALID_NODE_INDEX) and the node it is heading to.
yb_set_bot_goal_node(index, node) / yb_set_bot_goal_origin(index, const Float:origin[3])
Section titled “yb_set_bot_goal_node(index, node) / yb_set_bot_goal_origin(index, const Float:origin[3])”native yb_set_bot_goal_node (index, node);native yb_set_bot_goal_origin (index, const Float:origin[3]);Force the bot to go to a node / world origin. Returns 1 on success.
yb_get_bot_path_length(index) / yb_get_bot_path_node(index, offset)
Section titled “yb_get_bot_path_length(index) / yb_get_bot_path_node(index, offset)”native yb_get_bot_path_length (index);native yb_get_bot_path_node (index, offset);Remaining path length in nodes, and the path node at offset from the current path cursor (0 = next node, YB_INVALID_NODE_INDEX when none).
yb_is_bot_stuck(index) / yb_get_bot_stuck_time(index)
Section titled “yb_is_bot_stuck(index) / yb_get_bot_stuck_time(index)”native bool:yb_is_bot_stuck (index);native Float:yb_get_bot_stuck_time (index);Whether the bot is stuck, and cumulative stuck time in seconds.
yb_is_bot_camping(index)
Section titled “yb_is_bot_camping(index)”native bool:yb_is_bot_camping (index);Returns true when the bot is camping.
yb_set_bot_movement(index, bool:movement) / yb_is_bot_movement(index)
Section titled “yb_set_bot_movement(index, bool:movement) / yb_is_bot_movement(index)”native bool:yb_set_bot_movement (index, bool:movement);native bool:yb_is_bot_movement (index);Freeze / unfreeze bot movement, and query the state.
yb_set_bot_simulation(index, bool:simulate) / yb_is_bot_simulating(index)
Section titled “yb_set_bot_simulation(index, bool:simulate) / yb_is_bot_simulating(index)”native bool:yb_set_bot_simulation (index, bool:simulate);native bool:yb_is_bot_simulating (index);Suspend / resume all bot ticks (used by Takeover while a human controls the body), and query the state. Requires API 3.2+.
yb_is_bot_alive(index) / yb_is_bot_stale(index)
Section titled “yb_is_bot_alive(index) / yb_is_bot_stale(index)”native bool:yb_is_bot_alive (index);native bool:yb_is_bot_stale (index);Whether the bot is alive, and whether it is leaving the server (stale).
yb_get_bot_look_at(index, Float:origin[3]) / yb_set_bot_look_at(index, const Float:origin[3])
Section titled “yb_get_bot_look_at(index, Float:origin[3]) / yb_set_bot_look_at(index, const Float:origin[3])”native bool:yb_get_bot_look_at (index, Float:origin[3]);native bool:yb_set_bot_look_at (index, const Float:origin[3]);Read the bot look target, or force it (a zero vector restores AI aiming). Returns 1 on success.
yb_get_bot_enemy(index) / yb_get_bot_last_enemy(index) / yb_get_bot_last_victim(index)
Section titled “yb_get_bot_enemy(index) / yb_get_bot_last_enemy(index) / yb_get_bot_last_victim(index)”native yb_get_bot_enemy (index);native yb_get_bot_last_enemy (index);native yb_get_bot_last_victim (index);Current enemy, last enemy, and last victim entity indexes (YB_INVALID_ENTITY_INDEX when none).
yb_is_bot_enemy_reachable(index)
Section titled “yb_is_bot_enemy_reachable(index)”native bool:yb_is_bot_enemy_reachable (index);Whether the current enemy is reachable.
yb_get_bot_last_enemy_origin(index, Float:origin[3])
Section titled “yb_get_bot_last_enemy_origin(index, Float:origin[3])”native bool:yb_get_bot_last_enemy_origin (index, Float:origin[3]);Last known enemy origin. Returns 1 on success.
yb_has_graph()
Section titled “yb_has_graph()”native bool:yb_has_graph ();True when the current map has a graph file.
yb_get_node_count()
Section titled “yb_get_node_count()”native yb_get_node_count ();Total graph node count.
yb_is_node_valid(node)
Section titled “yb_is_node_valid(node)”native bool:yb_is_node_valid (node);True when the node index is valid.
yb_get_node_flags(node)
Section titled “yb_get_node_flags(node)”native YBNodeFlag:yb_get_node_flags (node);Node flags (see YBNodeFlag).
yb_get_node_origin(node, Float:origin[3])
Section titled “yb_get_node_origin(node, Float:origin[3])”native bool:yb_get_node_origin (node, Float:origin[3]);Stores the node origin. Returns 1 on success.
yb_get_nearest_node(const Float:origin[3])
Section titled “yb_get_nearest_node(const Float:origin[3])”native yb_get_nearest_node (const Float:origin[3]);Graph node nearest to the location (YB_INVALID_NODE_INDEX when none).
yb_find_nearest_node(const Float:origin[3], Float:maxDistance = 9999999.0)
Section titled “yb_find_nearest_node(const Float:origin[3], Float:maxDistance = 9999999.0)”native yb_find_nearest_node (const Float:origin[3], Float:maxDistance = 9999999.0);Nearest node within maxDistance.
yb_find_farest_node(const Float:origin[3], Float:maxDistance = 32.0)
Section titled “yb_find_farest_node(const Float:origin[3], Float:maxDistance = 32.0)”native yb_find_farest_node (const Float:origin[3], Float:maxDistance = 32.0);Node farthest from the origin beyond maxDistance (despite the name, the second param is a minimum distance).
yb_find_nearest_node_in_radius(const Float:origin[3], Float:radius)
Section titled “yb_find_nearest_node_in_radius(const Float:origin[3], Float:radius)”native yb_find_nearest_node_in_radius (const Float:origin[3], Float:radius);Nearest node within radius.
yb_get_node_distance(srcNode, destNode)
Section titled “yb_get_node_distance(srcNode, destNode)”native Float:yb_get_node_distance (srcNode, destNode);Distance between two nodes in units, -1 when a node is invalid.
yb_is_node_reachable(srcNode, destNode)
Section titled “yb_is_node_reachable(srcNode, destNode)”native bool:yb_is_node_reachable (srcNode, destNode);True when the two nodes are reachable from each other.
yb_get_node_radius(node) / yb_get_node_light(node)
Section titled “yb_get_node_radius(node) / yb_get_node_light(node)”native Float:yb_get_node_radius (node);native Float:yb_get_node_light (node);Node radius and light level (0 when invalid).
yb_get_node_link_count(node) / yb_get_node_link(node, index) / yb_get_node_link_flags(node, index)
Section titled “yb_get_node_link_count(node) / yb_get_node_link(node, index) / yb_get_node_link_flags(node, index)”native yb_get_node_link_count (node);native yb_get_node_link (node, index);native yb_get_node_link_flags (node, index);Outgoing link count, link target node (YB_INVALID_NODE_INDEX when none), and link flags.
yb_get_random_node(type)
Section titled “yb_get_random_node(type)”native YBNodeType:yb_get_random_node (type);Random node of the given type (see YBNodeType), YB_INVALID_NODE_INDEX when none.
yb_get_graph_author(output[], len) / yb_get_graph_modified(output[], len)
Section titled “yb_get_graph_author(output[], len) / yb_get_graph_modified(output[], len)”native yb_get_graph_author (output[], len);native yb_get_graph_modified (output[], len);Copy the graph author / modifier strings. Return number of characters copied.
Requires the chat extension (IBotChatAPI, available when API >= 3.6).
yb_bot_say(index, const message[], bool:team_only = false, bool:force = false)
Section titled “yb_bot_say(index, const message[], bool:team_only = false, bool:force = false)”native bool:yb_bot_say (index, const message[], bool:team_only = false, bool:force = false);Queues a bot text message. force bypasses the global chat cvar. Returns 1 when queued.
yb_set_bot_chat(index, YBChatMode:mode) / yb_get_bot_chat(index)
Section titled “yb_set_bot_chat(index, YBChatMode:mode) / yb_get_bot_chat(index)”native bool:yb_set_bot_chat (index, YBChatMode:mode);native YBChatMode:yb_get_bot_chat (index);Set / get who may chat for the bot (see YBChatMode).
Forwards
Section titled “Forwards”Implement any of these in your plugin - no registration needed.
yb_bot_spawned(index)
Section titled “yb_bot_spawned(index)”forward yb_bot_spawned (index);Called when a bot is spawned.
yb_bot_killed(victim, killer)
Section titled “yb_bot_killed(victim, killer)”forward yb_bot_killed (victim, killer);Called when a bot is killed.
yb_bot_removed(index, bool:kicked)
Section titled “yb_bot_removed(index, bool:kicked)”forward yb_bot_removed (index, bool:kicked);Called when a bot is removed.
yb_chat_pre(sender, const message[], bool:team_only, YBChatSource:source)
Section titled “yb_chat_pre(sender, const message[], bool:team_only, YBChatSource:source)”forward yb_chat_pre (sender, const message[], bool:team_only, YBChatSource:source);Called before a text chat message is emitted. Return PLUGIN_HANDLED to block it. The Chat AI plugin uses this to replace core-AI/human chat with LLM replies.
yb_chat_post(sender, const message[], bool:team_only, YBChatSource:source)
Section titled “yb_chat_post(sender, const message[], bool:team_only, YBChatSource:source)”forward yb_chat_post (sender, const message[], bool:team_only, YBChatSource:source);Called after a text chat message is emitted.