Gamemode Creation

From Garry's Mod
Jump to: navigation, search

Contents

Gamemode Content

Gamemode content such as maps, models and sounds should be placed in gamemodes/content/ folder. (ie gamemodes/content/models/..).

Gamemode Folder

To create a new gamemode you need to create a new folder in the gamemodes folder. The folder should take the name of your gamemode. Inside of that folder there should be a text file named whatever your folder is.

For instance, if my gamemode was called "SuperKillers", I would create a folder in "garrysmod/gamemodes/" called "superkillers". Then inside that folder I would create a text file called "superkillers.txt".

Note that in previous versions of Garry's Mod this file was always called "info.txt" - but was changed in Version 13 to reflect the changes to the content.

Gamemode Text File

The .txt file you created needs to be a keyvalues file.

"superkillers"
{
	"base"		"base"
	"title"		"Super Killers"
	"maps"		"^sk_"
	"menusystem"	"1"
	"workshopid"	"15895"

	"settings"
	{
		1
		{
			"name"		"sk_maxfrags"
			"text"		"Max Frags"
			"help"		"The maxiumum number of frags before a map change"
			"type"		"numeric"
			"default"	"20"
		}

		
		2
		{
			"name"		"sk_grenades"
			"text"		"Allow Grenades"
			"help"		"If enabled then grenades are enabled"
			"type"		"checkbox"
			"default"	"1"
		}
	}
}
key description
base The gamemode you're deriving from. This will usually be base.
title The 'nice' title of your gamemode. Can contain spaces and capitals.
maps The map filter for your gamemode. This is used to correctly categorise maps in the map selector. This should only be set if the maps are unique to your gamemode.
menusystem Include and set to 1 if this gamemode should be selectable from the main menu
workshopid Optional. If your gamemode is on Workshop then this should be the workshopid of the file. (You won't have a workshopid until you upload - so you will need to set this in an update)
settings See Below

Settings

The settings table allows you to create server configuration convars for your gamemode. It's completely optional. Your text file doesn't have to have a settings section.

In previous versions of GMod this section used to have its own file, in gamemode/<gamemode>/content/settings/server_settings/. It was moved to the root folder to decrease load times.

These settings are configurable in the main menu in GMod. Each entry has a number of fields.


key description
name The name of the convar
text The text to show in game to describe this convar
help The help text to show on the convar (in the console)
type Either text, checkbox or numeric
default The default value for the convar

Menu Background Images

If you want to include backgrounds with your gamemode place them in gamemodes/<yourgamemode>/backgrounds/. They must all be jpg images.

Menu Logo Image

To supply a menu logo image place a png file in gamemodes/<yourgamemode>/logo.png. This image should be 128 pixels high and up to 1024 pixels wide. The default logo is 288 x 128.

Menu Icon

To supply a menu icon place a png file in gamemodes/<yourgamemode>/icon24.png. This image should ideally be 24x24 pixels but it can be up to 32x32. The server list displays the icons at 24x24 while the gamemode selection uses 32x32. Here's where it will appear.

MenuIcons.jpg

Init and Shared Files

Three files are needed for your gamemode to function properly. These go into your <gamemode>/gamemode/ folder.

init.lua

This file is called when the server loads the gamemode. The example below tells the resource system to send the two files to the client, and then loads shared.lua.

AddCSLuaFile( "cl_init.lua" )
AddCSLuaFile( "shared.lua" )

include( "shared.lua" )

shared.lua

This file sets some common variables and creates the Initialize function. This is the only function you NEED to define. All others will be called from the base gamemode.

GM.Name = "Super Killers"
GM.Author = "N/A"
GM.Email = "N/A"
GM.Website = "N/A"

function GM:Initialize()

end 

cl_init.lua

This file is called when the client loads the gamemode. You would put client specific things in here. We load shared.lua. Note that you can only 'include' files here that have been 'AddCSLuaFile'd on the server.

include( "shared.lua" )
Personal tools
Navigation