AMX Mod X Documentation

repository·master·Indexed 20 days ago

https://github.com/alliedmodders/amxmodx

A powerful Metamod plugin for Half-Life 1 providing extensive scripting capabilities for game engine manipulation, event logging, and entity modification. Includes documentation on intercepting network messages, modifying entities, using the Pawn Compiler, and managing WinCSX player statistics. Also contains technical details on building the AMXX installer in Delphi 7 and configuring the integrated PCRE library.

Tokens
61.9K
Snippets
162
Records
229
Agent score
69%

What's inside AMX Mod X

  1. What is AMX Mod X

    master

    AMX Mod X is a Metamod plugin for Half-Life 1. It provides a comprehensive scripting environment for the game engine and its mods.

    Key capabilities include:

    • Intercepting network messages.
    • Logging events and commands.
    • Intercepting client commands.
    • Setting CVars (Console Variables).
    • Modifying entities.
    • Extending native scripting via modules (e.g., MySQL, Sockets).
  2. Avoid POSIX API name clashes

    master

    If you use the PCRE POSIX interface (pcreposix.h) on a system that already has a POSIX regex library installed, you may encounter name clashes with functions like regcomp.

    To avoid this, you can compile PCRE with a flag to rename these functions. For example, using -Dregcomp=PCREregcomp will rename the function to PCREregcomp. You must then use these new names in your application code.

    CFLAGS='-Dregcomp=PCREregcomp -Dregexec=PCREregexec' ./configure
  3. Understand the PCRE API sets

    master

    PCRE provides several API sets depending on your language and the data type you are processing:

    • C APIs: Three distinct sets of functions for different character widths:
      • 8-bit library: Processes strings of bytes.
      • 16-bit library: Processes strings of 16-bit values.
      • 32-bit library: Processes strings of 32-bit values.
    • C++ Wrapper: A set of C++ wrapper functions (provided by Google Inc.) used to call the 8-bit PCRE library from C++.
    • POSIX-style C Wrapper: A set of C wrapper functions for the 8-bit library based on the POSIX regular expression API (found in libpcreposix). Note that while the interface is POSIX, the regex syntax and semantics remain Perl-compatible.
  4. Customize PCRE character tables

    master

    PCRE uses character tables for various functions. By default, pcre_chartables.c is a copy of pcre_chartables.c.dist which assumes ASCII coding.

    To use a different set of tables based on your system's C locale, use the --enable-rebuild-chartables flag during the ./configure step. This invokes the dftables program, which uses ANSI C functions (like isalnum(), isalpha(), etc.) to build the tables.

    Manual Customization: If you need to provide your own custom tables, edit pcre_chartables.c and rebuild PCRE. To prevent the build system from overwriting your changes, move pcre_chartables.c.dist out of the directory and replace it with your customized version.

    ./configure --enable-rebuild-chartables
  5. Navigate AMX Mod X help entries

    master

    When viewing long lists of commands via the help system, you can navigate through the entries using the following patterns:

    • To see more entries: Use the command followed by the next page number: amx_help <command> <page_number>.
    • To return to the beginning: Use the command followed by 1: amx_help <command> 1.
    amx_help <command> <page_number>
    amx_help <command> 1
  6. View available AMX Mod X commands

    master

    To see a list of available commands in the AMX Mod X console, use the help command pattern:

    amx_help <command_name> <argument>

    Note: The specific command prefix (e.g., amx_help) may vary depending on your configuration, but the pattern involves typing the help command followed by the command name in the console.

    amx_help <command_name> <argument>
  7. Install dependencies for the AMXX installer project

    master

    To build the AMXX installer project in Delphi 7 on Windows, you must install several specific dependencies from deps.zip.

    Prerequisites

    1. Ensure the Delphi IDE has been run at least once.
    2. Close the Delphi IDE before attempting any installation steps.
    3. Decompress deps.zip and verify the following folders/files are present:
      • flatstyle
      • indy9
      • jcl
      • jvcl
      • mxFlatPack
      • madCollection.exe

    Installation Steps

    1. madCollection

    Run madCollection.exe. Select "madExcept4" before clicking the Install button. Accept the license agreement, type yes when prompted, and click Install.

    2. JCL (Jedi Code Library)

    Open the jcl folder and run Install.bat. Accept the MPL 1.1 License and click Install. Follow any subsequent prompts by clicking Yes.

    3. JVCL (Jedi Visual Component Library)

    Open the jvcl folder and run install.bat. Click Next through the prompts until the Install button appears, then click it using default settings.

    4. mxFlatPack

    1. Open mxFlatPack\Component\mxFlatPack_D7.dpk in Delphi. (Ignore any resource file errors).
    2. Click Install in the Package window.
    3. Configure Library Path:
      • Go to Tools -> Environment Options -> Library tab.
      • Click the ... button next to Library path.
      • Click the ... button in the next window, locate the mxFlatPack\Component folder, and click OK.
      • Click Add, then OK until the IDE closes.

    5. Indy 9

    1. Open indy9\dclIndy70.dpk in Delphi. (Ignore resource file errors).
    2. Click Install in the Package window. If an error about a package that can't be installed appears, click OK and click Install a second time.
    3. Configure Library Path:
      • Go to Tools -> Environment Options -> Library tab.
      • Click the ... button next to Library path.
      • Click the ... button, locate the indy9 folder, and click OK.
      • Click Add, then OK until the IDE closes.

    6. FlatStyle

    1. Open flatstyle\Packages\FlatStyle_D6.dpk in Delphi. Close the document window for the .dpk file.
    2. Click Install in the Package window.
    3. Configure Library Path:
      • Go to Tools -> Environment Options -> Library tab.
      • Click the ... button next to Library path.
      • Click the ... button, locate the flatstyle\Source folder, and click OK.
      • Click Add, then OK until the IDE closes.

    Once all steps are complete, you can build the AMXInstaller.dpr project.

  8. Generate CRC32 for gamedata

    master

    To generate the 8-digit hex CRC required for gamedata CRC sections, use the standalone tools/crc32 helper.

    1. Build the tool using the provided build script.
    2. Run the binary against your target file to get the CRC value.
    # Build the tool
    ./tools/crc32/build.sh
    
    # Generate the 8-digit hex CRC
    ./tools/crc32/crc32 <path-to-binary>
  9. Use the PCRE POSIX-style API

    master

    The pcreposix library provides a POSIX-style wrapper around the native PCRE (Perl-Compatible Regular Expressions) 8-bit library. While the API follows POSIX conventions, the underlying syntax and semantics remain Perl-based.

    To use this API, include <pcreposix.h> and link against both -lpcreposix and -lpcre on Unix systems.

    #include <pcreposix.h>
    
    // Example usage pattern:
    regex_t preg;
    regcomp(&preg, "pattern", 0);
    // ... use regexec ...
    regfree(&preg);
  10. Use quantifiers and control greediness

    master

    PCRE quantifiers determine how many times a pattern element matches. By default, they are "greedy" (matching as much as possible). You can make them "ungreedy" (lazy) by appending a question mark ?.

    Common Abbreviations

    • * is equivalent to {0,}
    • + is equivalent to {1,}
    • ? is equivalent to {0,1}

    Greediness Examples

    • Greedy: /*.**/ applied to /* comment */ text /* comment */ will match the entire string from the first /* to the last */.
    • Ungreedy: /*.*?*/ will match each comment individually.

    PCRE_UNGREEDY Option

    If the PCRE_UNGREEDY option is set, quantifiers are ungreedy by default, and you must append a ? to make them greedy.

    # Greedy (matches as much as possible)
    .* 
    
    # Ungreedy/Lazy (matches as little as possible)
    .*? 
    
    # Doubled question mark (matches one digit by preference, but can match two if needed)
    \d??