Simple Gamemode Help

Hello face-punch,

I’m completely new to this but following some tutorials I’ve Tried to make a simple game-mode (Not showing up in gamemode list) with;

  • 3 Classes : Civilian ( Crowbar, 357 )
    Solider ( Ar2, Crowbar, Pistol )
    Engineer ( Physcannon, Physgun, Gmod_tool )

  • Smooth health bar

  • Menus

  • Custom ‘Q’ menu

Here’s my questions and I know that the folders are correct, Thanks in advance XD

  • Is all you need in the Garrysmod > Gamemodes >Zombiez > Gamemode
    folder for the gamemode to work (Correctly coded) cl_init.lua ,
    init.lua & shared.lua ?

  • If it is, what is wrong?

Here’s the code:

Shared.lua


GM.Name 		= "Zombiez" 
 GM.Author 		= "Naww" 
 GM.Email 		= "Tomb.95@hotmail.co.uk"
 GM.Website 	= "N/A"
 
 team.SetUp( 1, "Civillan", Color( 125, 125, 125, 255 ) ) 
 team.SetUp( 2, "Engineer", Color( 225, 225, 0 , 225 ) ) 
 team.SetUp( 3, "Solider", Color( 100, 100, 100, 255 ) )

cl_init.lua


 include( "shared.lua" )
 
 function set_team() 
 
 frame = vgui.Create( "DFrame" ) 
 frame:SetPos( 100, ScrH() / 2 )
 frame:SetSize( 300, 300 )
 frame:SetTitle( "Class Select" ) 
 frame:SetVisible( true ) 
 frame:SetDraggable( false ) 
 frame:ShowCloseButton( true ) 
 frame:MakePopup() 
 
 team_1 = vgui.Create( "DButton", frame ) 
 team_1:SetPos( 30, 30 )
 team_1:SetSize( 100, 50 ) 
 team_1:SetText( "Civillian" ) 
 team_1.DoClick = function()
 
     RunConsoleCommand( "team_1" ) 
 
 end 
 
 team_2 = vgui.Create( "DButton", frame ) 
 team_2:SetPos( 30, 85 )
 team_2:SetSize( 100, 50 ) 
 team_2:SetText( "Engineer" ) 
 team_2.DoClick = function()
 
     RunConsoleCommand( "team_2" ) 
 
 end 
 
 team_3 = vgui.Create( "DButton", frame ) 
 team_3:SetPos( 135, 30 )
 team_3:SetSize( 100, 50 ) 
 team_3:SetText( "Solider" ) 
 team_3.DoClick = function()
 
     RunConsoleCommand( "team_3" ) 

 end
 
 end 
 concommand.Add( "team_menu", set_team ) 
 include( 'shared.lua' )
 
function proplist()
		print ("List Opening")
		local props = {}
 
	props[1] = "models/props_junk/garbage_milkcarton002a.mdl"
	props[2] = "models/props_junk/PopCan01a.mdl"
	props[3] = "models/props_junk/garbage_takeoutcarton001a.mdl"
	props[4] = "models/props_junk/watermelon01.mdl"
	props[5] = "models/props_junk/garbage_metalcan001a.mdl"
	props[6] = "models/props_lab/box01a.mdl"
	props[7] = "models/props_lab/box01b.mdl"
 
	local slframe = vgui.Create("DFrame")
	local IconList = vgui.Create("DPanelList", slframe)
 
	slframe:Center()
	slframe:SetSize(250,200)
	slframe:SetTitle("Prop Catalog")
	slframe:MakePopup()
 
	IconList:EnableVerticalScrollbar( true )
	IconList:EnableHorizontal( true )
	IconList:SetPadding( 4 )
	IconList:SetPos(10,30)
	IconList:SetSize(200,160)
 
	for k,v in pairs(props) do
	local icon = vgui.Create( "SpawnIcon", IconList )
	icon:SetModel( v )
	IconList:AddItem( icon )
	icon.DoClick = function( icon ) surface.PlaySound( "ui/buttonclickrelease.wav" ) RunConsoleCommand("gm_spawn", v) end
	end
end
concommand.Add("slist", proplist)
 
function GM:OnSpawnMenuOpen( ply )
LocalPlayer():ConCommand("slist")
end

local smooth = 0 
hook.Add("HUDPaint", "HealthBar", function()
 
	local health = math.Clamp(LocalPlayer():Health(), 0, 100)
	smooth = math.Approach(smooth, health, 50*FrameTime())
									
 
	local red = (1 - smooth/100)^(1/2) * 255
	local grn = (smooth/110)^(1/2) * 255
	local blu = (smooth/200)^2 * 255
	local col = Color(red, grn, blu)
	
	local w, h = 60, 200
	local spacing = 32
 
	local equation = (h-8)*(smooth/100)+8
	
	draw.RoundedBox(
		4,
		ScrW() - w - spacing - 2,
		ScrH() - h - spacing - 2,
		w + 4,
		h + 4,
		Color( 30, 30, 30 )
	)
 
	draw.RoundedBox(
		4,
		ScrW() - w - spacing,
		ScrH() - equation - spacing,
		w,
		equation,
		col
	)
 


init.lua


  AddCSLuaFile( "cl_init.lua" )
 AddCSLuaFile( "shared.lua" )
 
 include( 'shared.lua' )
 
 function GM:PlayerInitialSpawn( ply )
 
     ply:ConCommand( "team_menu" )
 
 end
 
 function GM:PlayerLoadout(ply)
 
	ply:StripWeapons()
 
	if ply:Team() == 1 then
		ply:Give("weapon_357")
		ply:Give("weapon_crowbar")
		ply:SetModel( "models/player/gman_high.mdl" )
		
	elseif ply:Team() == 2 then
		ply:Give("weapon_physgun")
        ply:Give("weapon_physcannon")
		ply:Give("Gmod_tool")
		ply:SetModel( "models/player/kleiner.mdl" )
		ply:Give("item_battery", 5 )
		
	elseif ply:Team() == 3 then
 
        ply:Give( "weapon_ar2" )
        ply:GiveAmmo( 180, "ar2" )
		ply:Give("weapon_pistol")
		ply:GiveAmmo( 180, "ar2" )
        ply:SetModel( "models/player/barney.mdl" )

		
		
	end
 
end
 
 function team_1( ply ) 
 
     ply:SetTeam( 1 )
	 ply:Spawn()
 end 
 
 function team_2( ply ) 
 
     ply:SetTeam( 2 )
	 ply:Spawn()
 end 
 
 function team_3( ply ) 
 
    ply:SetTeam( 3 )
    ply:Spawn()
end 

 
 concommand.Add( "team_1", team_1 )
 concommand.Add( "team_2", team_2 )
 concommand.Add( "team_3", team_3 )
 
 
 

“What’s wrong?” is a bad way of asking for advice. Tell us what happens, if you get any errors, etc.

Sorry that wasn’t very clear.

The cl_init.lua , shared.lua and init.lua is in this directory >

H/programfiles/steam/steamapps/cookncrazy/garrysmod/garrysmod/gamemodes/zombiez/gamemode

but it dosen’t show up as an option for a gamemode when i try playing gmod???

any ideas?

Do you have an info.txt in gamemodes/zombiez

If you’re new to this, you should’ve downloaded and edited the skeleton gamemode created by garry for gamemode developers.

[lua]hook.Add(“HUDPaint”, “HealthBar”, function()

local health = math.Clamp(LocalPlayer():Health(), 0, 100)
smooth = math.Approach(smooth, health, 50*FrameTime())
								

local red = (1 - smooth/100)^(1/2) * 255
local grn = (smooth/110)^(1/2) * 255
local blu = (smooth/200)^2 * 255
local col = Color(red, grn, blu)

local w, h = 60, 200
local spacing = 32

local equation = (h-8)*(smooth/100)+8

draw.RoundedBox(
	4,
	ScrW() - w - spacing - 2,
	ScrH() - h - spacing - 2,
	w + 4,
	h + 4,
	Color( 30, 30, 30 )
)

draw.RoundedBox(
	4,
	ScrW() - w - spacing,
	ScrH() - equation - spacing,
	w,
	equation,
	col
)

[/lua]
to
[lua]hook.Add(“HUDPaint”, “HealthBar”, function()

local health = math.Clamp(LocalPlayer():Health(), 0, 100)
smooth = math.Approach(smooth, health, 50*FrameTime())
								

local red = (1 - smooth/100)^(1/2) * 255
local grn = (smooth/110)^(1/2) * 255
local blu = (smooth/200)^2 * 255
local col = Color(red, grn, blu)

local w, h = 60, 200
local spacing = 32

local equation = (h-8)*(smooth/100)+8

draw.RoundedBox(
	4,
	ScrW() - w - spacing - 2,
	ScrH() - h - spacing - 2,
	w + 4,
	h + 4,
	Color( 30, 30, 30 )
)

draw.RoundedBox(
	4,
	ScrW() - w - spacing,
	ScrH() - equation - spacing,
	w,
	equation,
	col
)

end)[/lua]

I haven’t got an info.txt in there, What should it contain?


 
"Gamemode"
{
	"name"		"King Of The Hill"
	"version"	"1.0"
 
	"author_name"	"Jova"
	"author_email"	""
	"author_url"	"JovaCentral.com"
 
	"info"		""
	"hide"		"0"
}
 

Tnx much XD, Hopefully that’ll work, Ill have to check when I get back home.

I have to say it; your name… no.