Garry's Mod Documentation

repository·master·Indexed 23 days ago

https://github.com/facepunch/garrysmod

Lua, text, and configuration extensions for Garry's Mod. Includes guides for installing and configuring the Trouble in Terrorist Town (TTT) gamemode, creating custom scripted weapons (SWEPs), and detailed entity definitions from base.fgd covering NPC behavior, light properties, and sandbox restrictions.

Tokens
40.4K
Snippets
54
Records
162
Agent score
79%

What's inside garrysmod

  1. Mod the TTT gamemode with custom weapons

    master

    You can customize TTT without modifying the core gamemode code. The recommended way to add content is by creating scripted weapons (SWEPs).

    • Custom Weapons: You can add your own scripted weapons independently. To learn how, refer to the GMod wiki regarding SWEPs.
    • Reference Implementation: You can find the scripts for standard TTT weapons in: \gamemodes\terrortown\entities\weapons\.
    • Base Class: The weapon_tttbase script contains documentation that is useful for creating TTT-compatible weapons.
    • Hooks: TTT provides various hooks for customization. Detailed information is available at http://ttt.badking.net/.
  2. Install the Trouble in Terrorist Town gamemode

    master

    If you are using a version of TTT included with Garry's Mod, no installation is required. If you have a .zip version of the gamemode, extract the contents into your Garry's Mod directory so that the path errorTown exists within the gamemodes folder.

    For local installation: X:\Steam\steamapps\common\garrysmod\garrysmod\

    For dedicated server (srcds) installation: X:\srcds\orangebox\garrysmod\

    X:\Steam\steamapps\common\garrysmod\garrysmod\
  3. Prepare a dedicated server for TTT

    master

    To run a stable Trouble in Terrorist Town server, follow these requirements:

    1. Install CS:S Content

    TTT requires Counter-Strike: Source (CS:S) content to be installed. Without it, you will experience issues such as floating grenades, floating weapons, and instant reloading.

    • If issues persist after installing CS:S, try moving the cstrike directory into the orangebox directory (e.g., \servername\orangebox\cstrike\).

    2. Configure Map Cycling

    To enable automatic map switching every few rounds, place a mapcycle.txt file in the \garrysmod\ directory. This file should contain a list of map names (similar to standard Source engine mapcycles). Using CS:S maps is recommended.

    Add the following to your server.cfg to ensure TTT's internal logic (like voice handling and anti-cheat) works correctly:

    • sv_alltalk 0: Prevents sv_alltalk from overriding TTT's voice handling, which would otherwise allow dead players to talk to living players.
    • sv_allowcslua 0: Disables Client-Side Lua to prevent easy cheating.
    sv_alltalk 0
    sv_allowcslua 0
  4. How activator filters work

    master

    An activator filter is a BaseFilter used to test whether an entity (the activator) meets specific criteria. Filters can be configured in two modes via the Negated(choices) property:

    • Allow (0): Only entities matching the criteria pass.
    • Disallow (1): Only entities that do NOT match the criteria pass.

    To test an entity, use the input TestActivator(void) command. This will trigger either the output OnPass(void) or output OnFail(void) based on the result.

    You can build complex logic using filter_multi, which combines multiple sub-filters using either AND (all must pass) or OR (any must pass) logic.

  5. Use func_instance_io_proxy for cross-instance communication

    master

    The func_instance_io_proxy allows entities inside an instance to communicate with entities outside the instance.

    1. Place a func_instance_io_proxy inside the instance.
    2. Entities inside the instance send a ProxyRelay message to the proxy.
    3. The proxy then triggers its OnProxyRelay output, which can be used to trigger entities outside the instance.
    // Inputs
    input ProxyRelay(string) : "This message will get relayed and will be available from the instance."
    
    // Outputs
    output OnProxyRelay(void) : "A message from outside can trigger this to cause something to happen in the instance."
  6. Spawn templates with point_template and env_entity_maker

    master

    To create repeatable objects or groups of entities, use a combination of point_template and env_entity_maker.

    1. Define the Template (point_template)

    Group your entities and add a point_template. When instantiated, the template automatically renames its internal entities (e.g., original_name&0000) and reconnects their I/O to ensure they function correctly as independent instances.

    2. Spawn the Template (env_entity_maker)

    Place an env_entity_maker where you want the template to appear. Set the EntityTemplate key to the name of your point_template.

    Key env_entity_maker Spawnflags

    • 1: Enable AutoSpawn (spawns when there is room and the player is looking elsewhere).
    • 4: AutoSpawn even if the player is looking.
    • 8: ForceSpawn only if there is room.
    • 16: ForceSpawn only if the player is NOT looking.
  7. Use func_instance to place map instances

    master

    The func_instance entity allows you to place an instance of a map file. You can translate, rotate, and use replacement parameters to modify the contents of the instance.

    To pass values into an instance, use the $variable syntax within the instance's key/value pairs. The func_instance then uses its replace keys to substitute those variables with specific values.

  8. Influence bot pathfinding with nav entities

    master

    Use navigation entities to control how bots move through your map.

    Block Navigation

    • func_nav_blocker: A brush entity that blocks nav areas touching its AABB. Use input BlockNav(string) to start blocking and input UnblockNav(void) to stop.
    • func_nav_avoidance_obstacle: A brush entity that tells bots to avoid nav areas touching its AABB.

    Influence Navigation Cost

    • func_nav_avoid: Increases pathfinding cost to make bots avoid a region.
    • func_nav_prefer: Decreases pathfinding cost to make bots prefer a region.

    Common Properties for Influence Entities:

    • tags(string): A space-delimited list of labels (e.g., bomb_carrier, common, mission_sniper). Bots with matching tags will react to the entity.
    • team(choices): Which team is affected (-2 for Everyone, 0 for Team 0, 1 for Team 1).