GMA

From Valve Developer Community
Jump to navigation Jump to search
This article or section is a stub. You can help by expanding it.

GMA ("Garry's Mod Addon") is an archive file extention used by Garry's Mod Garry's Mod to store addon content, such as models, materials, sounds and maps.

GMA files from the Steam Workshop are stored in these folders: \Steam\steamapps\workshop\content\4000\, GarrysMod\garrysmod\cache\workshop. The game will also load GMA files from GarrysMod\garrysmod\addons.

Confirm.pngConfirm: Since GMod used to install addons there (and they've since been cleaned out of there automatically), is there any code in the game that checks for GMAs in /addons/ and removes them?

GMA files installed from Steam Workshop are named by their Workshop item's ID in \cache\workshop\, but they preserve their original filenames in \content\4000. The item ID is instead used as the name of the folder where the .gma is located.

Tip.pngTip: Assign the .gma file extension to GarrysMod\bin\gmad.exe to extract such archives by double-clicking them.
Note.pngNote: Older versions of Garry's Mod installed GMA files into GarrysMod\garrysmod\addons. This was changed in the early 2020s.[When?]
Note.pngNote: Some sources say that GMAs cannot exceed 2 gigabytes. This is not a limit in the x64 versions of gmad or gmpublish available in the x86-64 branch of the game. However, the game will error when loading absurdly big GMAs.
Confirm.pngConfirm: Above 4GB or above 2GB?

GMA tools

Todo: Expand sections about other tools - what do they offer?

The following tools are unsupported and are unlikely to function with modern versions of Garry's Mod.

Publishing an addon using GMA

Note.pngNote: Community tools greatly simplify the process.

Addons for Garry's Mod need to be packaged into GMA archives to be distributed on Steam Workshop. The required components for a compile are:

  1. Addon assets & content (models, materials, maps, sounds, Lua code, etc).
  2. An addon.json file, containing information about the addon.
  3. A compiling application, in this case, gmad.exe
  4. A publishing application, in this case, gmpublish.exe

Setting up

Assuming your assets are ready, you will need to create a new folder (will be referred to as the root or addon folder), in which your assets will be stored. Addon folders use the game folder structure, however some folders are not allowed. Generally, an addon folder looks like this:

Example_addon
	addon.json
	lua/
	maps/
	backgrounds/
	materials/
	models/
	sound/
	gamemodes/
	scenes/
	scripts/vehicles/
	particles/
	resource/fonts/
	resource/localization/
Note.pngNote: You can see the fully detailed list of allowed filetypes and locations here.
Tip.pngTip: You can check if your addon structure is functional by putting the addon folder into /garrysmod/adddons/. The game has a legacy system that mounts non-GMA addons from that folder. It's also convenient to develop starting with a non-GMA addon for easier file management.
Warning.pngWarning: .sw.vtx files are unused by the game and therefore not allowed. You can safely remove them.
Warning.pngWarning: An addon folder will refuse to become a .gma if it contains files not allowed by the whitelist. There is a workaround mentioned below.

addon.json

addon.json is a mandatory file for compiling GMA files. It contains basic metadata about the addon, mostly used for the Workshop page. Here is an example of an addon.json file:

{
	"title"		:	"My Server Content",
	"type"		:	"ServerContent",
	"tags"		:	[ "roleplay", "realism" ],
	"ignore"	:
	[
		"*.psd",
		"*.vcproj",
		"*.svn*"
	]
}
  • title is the name of your addon as seen in the Workshop.
  • type is the type of your addon. Note that mistagged addons (e.g. an NPC tagged as a weapon) are against Facepunch's workshop rules. Allowed values are:
"ServerContent"
"gamemode"
"map"
"weapon"
"vehicle"
"npc"
"tool"
"effects"
"model"
"entity"
  • tags is up to two of these Workshop tags.
    Confirm.pngConfirm: Gmpublisher can add up to three. Is this a gmpublish or a gmad limitation?
"fun"
"roleplay"
"scenic"
"movie"
"realism"
"cartoon"
"water"
"comic"
"build"
  • ignore is a wildcard list of files to ignore when creating the addon file. The example shown above will prevent all .psd, .vcproj and .svn files from stopping you from making a .gma. The number of ignored files or filetypes is unlimited. Common unallowed file types are: .psd, .blend, .max, .DS_Store, .db, .bak, .tmp, .pdf, .txt (other than vehicle scripts), .docx, .rtf, .zip, .rar and others.

Compiling with gmad

Open your GarrysMod\bin folder and find gmad.exe. Drag your addon's root folder onto it, probably from another file manager window. If successful, a new .gma file should appear in the same directory as your input root folder.
Alternatively, open the Command Prompt in GarrysMod\bin. Then write this command putting actual paths in:

gmad.exe create -folder "Full path to your addon folder" -out "Full path to the folder where the GMA file should be created"

The -out parameter is optional, and if not set, the GMA file will be created in the same directory as the input folder.

Testing

It is recommended to test your compiled addon before distributing it on the Workshop. To do this, put your compiled GMA file in the GarrysMod\garrysmod\addons folder and load up the game to see if your addon is there.

Creating a thumbnail

Your addon's thumbnail should be a 512x512 .jpg file. Do not save it to anywhere inside the addon.

Tip.pngTip: The uploader does not force any JPEG quality level. It is advisable to save your thumbnails in the highest possible quality while staying under a megabyte.
Tip.pngTip: Gmpublisher allows .gif files as thumbnails.

Publishing

Open the Command Prompt in your GarrysMod\bin directory. Write this command, changing the GMA and thumbnail (icon) file paths to yours:

gmpublish.exe create -addon "C:\example_addon.gma" -icon "C:\example_thumbnail.jpg"

If successful, you will see the ID of your newly created Workshop item. New addons are private by default - you will need to change that by going to the addon's Workshop page.

Warning.pngWarning: Gmpublish will fail to upload files from non-ASCII paths.
Warning.pngWarning: Unsuccessful uploads will create empty addons with no thumbnail or name. Delete them.

Remember Steam Workshop's rules.

  • Do not publish pirated or leaked content
  • Do not publish malicious code
  • Do not publish content that promotes discrimination, violence, or illegal acts
  • Do not publish broken mods or empty GMAs
  • If you use someone else's work, you must get their permission and give them credit in the description
  • NSFW content (nudity, gore) should be marked as such through content descriptors on the addon page
  • Your addon's thumbnail should represent what is actually in the mod

See Also

External Links