How to Build Weapons and Add-Ons for Garry's Mod

TIME : 2016-01-08
How to Build Weapons and Add-Ons for Garry's Mod

Garry's Mod is a sandbox that can be extended with almost anything you can imagine, and packaging your creations into an add-on is the standard way to share them. Here is a straightforward walkthrough for building an add-on folder, plus a note on what it takes to make actual weapons.

Structuring a Basic Add-On

Start by creating a new folder inside your Garry's Mod addons directory. For this example, call it something like downloaded-map.

Inside that folder, recreate the same directory layout the game normally uses. In other words, mirror the paths where files usually live. A map file with a .bsp extension normally sits in:

steamapps\garrysmod\garrysmod\maps

To ship that map through an add-on, you would instead place a folder named maps inside your add-on folder and drop the .bsp file into it:

steamapps\garrysmod\garrysmod\addons\<my addon>\maps\downloadedmapfile.bsp

Those two paths point to the same result, which is exactly the point: the add-on folder keeps everything self-contained.

Adding the info.txt File

Next, create a plain text file named info.txt in the root of your add-on folder and give it an AddonInfo block. Everything inside the braces is optional, so include only what you need:

"AddonInfo"
{
  "name"      "my addon name"
  "version"    "1"
  "up_date"   "any date you like"
  "author_name" "your name"
  "author_email" "your email (optional)"
  "override"   "0"
}

The override value controls whether files with matching names get overwritten. If you are unsure what you are doing, leave it out. For the complete list of supported fields, search for Garry's Mod add-on documentation.

Making Actual Weapons

Weapons are a completely different undertaking. In Garry's Mod they are written as Scripted Weapons (SWEPs) using the Lua scripting language. Search for a guide such as "how to make a Garry's Mod SWEP" to find current tutorials, then build your weapon logic on top of the add-on structure above.