AMX Mod X (Pawn) Code Style Guide

SkillDev tools

Helps with AMX Mod X (Pawn) coding conventions and best practices.

Available today. Use it from your connected AI after setup.

Connect ahel once, and every AI you use reads what you have installed.

Then ask your AI: use the AMX Mod X (Pawn) Code Style Guide skill

What this skill tells your AI

The instructions your AI receives, as published by hedgefog/amxx-modding-kit in .agents/skills/amxmodx/SKILL.md and read by ahel’s review.

This document provides an overview of coding conventions for AMX Mod X projects. Each topic is covered in detail in its own file.

Core Conventions

CategoryDescription
BasicsSyntax, basics
Code StyleFile structure, formatting, braces, spacing, plugin registration
Naming ConventionsHungarian notation, variable prefixes, naming patterns
Constants & EnumsDefine constants, enums, TASKID constants
MacrosCommon macros, IS_PLAYER, patterns to avoid
Function DeclarationsReturn types, @ prefix, static variables
ValidationsFM_NULLENT, entity checks, player validation, early returns

API Patterns

CategoryDescription
HooksHam, FakeMeta, ReAPI, Event, Message hooks and handles
ForwardsCreateMultiForward, ExecuteForward, pre/post patterns
NativesNative registration and implementation
CallbacksTasks, SQL queries, CVar queries
MenusMenu creation, callbacks, and patterns
CommandsClient, server, and console commands
CVarsCVar creation, binding, and change hooks

Performance & Data

CategoryDescription
OptimizationsNative call reduction, dynamic hooks, model path caching
Data StructuresArrays, Tries, entity access, strings

Quick Reference: Best Practices Summary

Code Style

  1. Always use #pragma semicolon 1 at file start
  2. Use Hungarian notation for all variable names
  3. Use K&R brace style (opening brace on same line)
  4. Pass plugin info directly to register_plugin() - avoid macros
  5. Group hooks and functions with section comments

Constants & Validation

  1. Use FM_NULLENT instead of -1 or 0 for null entity checks
  2. Always check FM_NULLENT after entity creation before processing
  3. Return FM_NULLENT not 0 for failures - 0 is worldspawn
  4. Return early for invalid conditions

Macros

  1. Don't redefine macros - use shared definitions from includes
  2. Never use MACRO()_Suffix patterns in code - only in macro definitions

Function Declarations

  1. Use @ prefix only for OOP-like methods: @{EntityName}_{MethodName}
  2. Never add public keyword to @ prefixed functions
  3. Use const prefix for all handle arguments
  4. Use const &this for "this" argument in OOP-like methods
  5. Use static variables in frequently called class methods
  6. Declare and assign static on same line using semicolon separator

Hooks

  1. Ham hooks must return HAM_* constants
  2. FakeMeta hooks must return FMRES_* constants
  3. ReAPI hooks must return HC_* constants
  4. Message hooks must return PLUGIN_* constants
  5. Hook handle variables: g_pfwham (Ham), g_pfwfm (FakeMeta)
  6. Inline get_user_msgid when only used once in register_message

Forwards

  1. Forward names use LibraryName_OnSomething - not Fw_ prefix
  2. Multi-forward handle variables use g_pfw prefix

Natives & Callbacks

  1. Native implementations use Native_ prefix with const for arguments
  2. Task callbacks use Task_ prefix with offset in task ID
  3. SQL callbacks use Callback_SQLQuery_{Name} prefix

Menus

  1. Menu callbacks use Callback_Menu_{Name} prefix
  2. Use enum for menu items to avoid index mistakes
  3. Destroy dynamic menus in callback with menu_destroy

Commands & CVars

  1. Command handlers use Command_ prefix, server commands use ServerCommand_
  2. Use register_concmd for admin commands that should work from RCON
  3. Avoid client_cmd - use engclient_cmd for server-side execution
  4. Use create_cvar instead of deprecated register_cvar
  5. Use bind_pcvar_* instead of get_pcvar_* for cvar access

Optimizations

  1. Minimize native calls in hot paths
  2. Use single global g_pTrace - never create trace handles per-call
  3. Register high-frequency hooks dynamically
  4. Use xs_vec_set instead of xs_vec_copy for vector initialization
  5. Cache model index with static inside function, not in separate global

Naming Conventions

  1. Sound arrays use g_rgsz prefix with g_i*Num counter
  2. Message IDs use gmsg prefix (without underscore)
  3. Player arrays use g_rg*[MAX_PLAYERS + 1] with type prefix
  4. Don't use id for players - use pPlayer
  5. Don't use index for entities - use pEntity

Data Structures

  1. Always free dynamic handles - ArrayDestroy, TrieDestroy in plugin_end()

Signals

GitHub stars
32
Forks
4
Last commit
Aug 2026
Advanced
Catalog kind
skill
Gateway key
amxmodx-basics
Source
github.com/hedgefog/amxx-modding-kit