Making your first gamemode
From GMod Wiki
Line 1: | Line 1: | ||
+ | {{Deletion|Reason = Almost no information, and we have 3 other game mode creation tutorials that are way more useful}} | ||
+ | |||
+ | |||
+ | |||
__NOTOC__{{Article| | __NOTOC__{{Article| | ||
name = Making your first Gamemode| | name = Making your first Gamemode| | ||
Line 107: | Line 111: | ||
Congratulations, you made your first Gamemode! You can now create a server with this Gamemode and play with your friends! | Congratulations, you made your first Gamemode! You can now create a server with this Gamemode and play with your friends! | ||
Have a nice battle! | Have a nice battle! | ||
- | |||
- |
Latest revision as of 06:00, 2 December 2011
This page has been nominated for deletion. Deletion is due within approximately 30 days from nomination, unless the deletion has been disputed on the talk page. See more pages nominated for deletion here. Reason for deletion: Almost no information, and we have 3 other game mode creation tutorials that are way more useful Last Edit was made on 12/02/2011 |
Making your first Gamemode |
Description: | You will learn how to make an elementary Gamemode. |
Original Author: | Shen |
Created: | November 26, 2010 |
Before you start
Before starting to code, you must think about these questions:
What will be the gamemode about? A deathmatch Gamemode.
How many teams will this Gamemode have? There will be none for me.
Creating the folder, and the info file
Now that we have acquired the ideas, we're going to create the base of the Gamemode.
1. Start by creating a folder named "MyGamemode" in the /gamemodes folder.
2. Continue by going inside and creating a text file called "info.txt".
We're not finished yet, we have to fill in the "info" file various informations about the gamemode:
"Gamemode" { "name" "MyGamemode" "version" "1.0" "author_name" "Me" "author_email" "[email protected]" "author_url" "" "icon" "" "info" "Pwn everyone!" "hide" "" }
Now, we may start the coding..
Coding
Here, we are, the core of the Gamemode.
You may create a "gamemode" folder and 3 files inside:
shared.lua init.lua cl_init.lua
No matter what, these files should ALWAYS BE here.
Now, your Gamemode folder should look like this:
MyGamemode/ MyGamemode/info.txt MyGamemode/gamemode MyGamemode/gamemode/cl_init.lua MyGamemode/gamemode/init.lua MyGamemode/gamemode/shared.lua
What we want to do is a simple gamemode, with no complex stuff: no HUD, only weapons.
Let's put the following in the cl_init.lua script.
include( 'shared.lua' )
What's this? It's a command to include the shared.lua. Much more like to use its functions.
If you learned to make a HUD in any other tutorial, then you may put a code here.
Now, we may start working on init.lua: THE core of the Gamemode.
AddCSLuaFile( "shared.lua" ) AddCSLuaFile( "cl_init.lua" ) include( 'shared.lua' )
Well, I've already explained what's include, but what is AddCSLuaFile? This very useful function serves to make the client download this script, so he can also use it. Now, append the following in the init.lua script:
function GM:PlayerLoadout( pl ) pl:Give( "weapon_pistol" ) pl:Give( "weapon_smg1" ) pl:Give( "weapon_crowbar" ) pl:GiveAmmo( 999, "pistol" ) pl:GiveAmmo( 999, "smg1" ) end
Wow wow, what is this?
This function is executed to decide what the player should get when (s)he spawns: In this case, the player will get:
A pistol with 999 ammo, A SMG with 999 ammo and a crowbar!
We can almost say we've finished writing your first Gamemode, but we're not done yet! We have to complete the shared.lua file!
GM.Name = "MyGamemode" GM.Author = "Me" GM.Email = "[email protected]" GM.Website = "N/A"
Basically, the 4 first lines are informations about the name of the gamemode and its author.
Ending
Congratulations, you made your first Gamemode! You can now create a server with this Gamemode and play with your friends! Have a nice battle!