Garrys mod gamemode for gmod13

Hi I have been trying to make a gamemode for gmod13 problem is I only have gmod12 gamemodes to base it off of.

I am currently getting this error when I hit the water on the map.



[ERROR] gamemodes/name/gamemode/cl_huds.lua:136: attempt to call method 'Alive' (a nil value)
  1. Paint - gamemodes/name/gamemode/cl_huds.lua:136
   2. v - gamemodes/name/gamemode/cl_huds.lua:182
    3. unknown - lua/includes/modules/hook.lua:82



And this is the function that contains the line the error is referring to



function FMHUD:Paint()
	
	local Name = LocalPlayer()
	
	if Name:IsValid() && Name:Alive() then
		if Name:Alive() && Name:IsValid() then
			draw.RoundedBox(4, 4, (ScrH() - (self.BlockTall*2) - self.Tall - self.Space), self.BlockWide, ((self.BlockTall*2) + self.Tall), Color(0,0,0,200))
		
			local HH = LocalPlayer():Health()
			local HF = math.Clamp(HH/100, 0, 1)
			local HW = (self.Wide - self.MinWide) * HF
			
			draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*3) - (self.Space*4)), self.MinWide + HW, self.Tall, Color(221,82,82,255))
			draw.SimpleText(math.Max(HH, 0).." HP","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall*2) - (self.Tall/2) - (self.Space*4)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
	
			if IsValid(LocalPlayer():GetActiveWeapon()) then
				if LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) > 0 || LocalPlayer():GetActiveWeapon():Clip1() > 0 then
					local CH = (LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) + LocalPlayer():GetActiveWeapon():Clip1())
					local CF = math.Clamp(CH/100, 0, 1)
					local CW = ((self.Wide) - self.MinWide) * CF
					
					draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.MinWide + CW, self.Tall, Color(0,242,242,255))
					draw.SimpleText(CH.." Bullets","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
				else
					draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.Wide, self.Tall, Color(0,242,242,255))
					draw.SimpleText("Ammo","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
				end
			else
				draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.Wide, self.Tall, Color(0,242,242,255))
				draw.SimpleText("Ammo","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			end
	
			if LocalPlayer():GetNWInt("Cash") != nil && LocalPlayer():GetNWInt("Cash") != "" then
				local MH = LocalPlayer():GetNWInt("Cash")
				local MF = math.Clamp(MH / 5000, 0, self.Wide)
				local MW = (MF + 5)
					if MH < 750000 then
					draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), MW, self.Tall, Color(0,221,55,255))
					draw.SimpleText("$"..MH,"FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
				else
					draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), MW, self.Tall, Color(0,221,55,255))
					draw.SimpleText("$"..MH.." OMG!?!","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
				end
			else
					draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), self.Wide, self.Tall, Color(0,221,55,255))
					draw.SimpleText("Profile Loading...","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			end
		end
	end
end
hook.Add("HUDPaint","FMHUD.Paint",function() FMHUD:Paint() end)


if I change

“if Name:Alive() then”
to
“if Name:IsValid() && Name:Alive() then”

What happens is my HUD disappears and my player is stuck.

Whats missing?

Help much appreciated

dont think this is it but you are doing if Name:IsValid() && Name:Alive() then twice

I added the first one it removes the errors from console. Because it checks “IsValid()” first them “Alive()”.

The error would show because it would check “Alive()” on an invalid player

I wanted to see what would happen when I switched them.

Here is the original function



function FMHUD:Paint()
	if LocalPlayer():Alive() && LocalPlayer():IsValid() then
		draw.RoundedBox(4, 4, (ScrH() - (self.BlockTall*2) - self.Tall - self.Space), self.BlockWide, ((self.BlockTall*2) + self.Tall), Color(0,0,0,200))
	
		local HH = LocalPlayer():Health()
		local HF = math.Clamp(HH/100, 0, 1)
		local HW = (self.Wide - self.MinWide) * HF

		draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*3) - (self.Space*4)), self.MinWide + HW, self.Tall, Color(221,82,82,255))
		draw.SimpleText(math.Max(HH, 0).." HP","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall*2) - (self.Tall/2) - (self.Space*4)), color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)


		if ValidEntity(LocalPlayer():GetActiveWeapon()) then
			if LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) > 0 || LocalPlayer():GetActiveWeapon():Clip1() > 0 then
				local CH = (LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) + LocalPlayer():GetActiveWeapon():Clip1())
				local CF = math.Clamp(CH/100, 0, 1)
				local CW = ((self.Wide) - self.MinWide) * CF
				
				draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.MinWide + CW, self.Tall, Color(0,242,242,255))
				draw.SimpleText(CH.." Bullets","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			else
				draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.Wide, self.Tall, Color(0,242,242,255))
				draw.SimpleText("Ammo","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			end
		else
			draw.RoundedBox(4, (self.Space*2), (ScrH() - (self.Tall*2) - (self.Space*3)), self.Wide, self.Tall, Color(0,242,242,255))
			draw.SimpleText("Ammo","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - self.Tall - (self.Tall/2) - (self.Space*3)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
		end

		if LocalPlayer():GetNWInt("Cash") != nil && LocalPlayer():GetNWInt("Cash") != "" then
			local MH = LocalPlayer():GetNWInt("Cash")
			local MF = math.Clamp(MH / 5000, 0, self.Wide)
			local MW = (MF + 5)

			if MH < 750000 then
				draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), MW, self.Tall, Color(0,221,55,255))
				draw.SimpleText("$"..MH,"FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			else
				draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), MW, self.Tall, Color(0,221,55,255))
				draw.SimpleText("$"..MH.." OMG!?!","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
			end
		else
				draw.RoundedBox(4, (self.Space*2), ScrH() - self.Tall - (self.Space*2), self.Wide, self.Tall, Color(0,221,55,255))
				draw.SimpleText("Profile Loading...","FMHUD_Font", self.Wide/2 + (self.Space*2), (ScrH() - (self.Tall/2) - (self.Space*2)), Color(255,255,255,255),TEXT_ALIGN_CENTER,TEXT_ALIGN_CENTER)
		end

	end
end
hook.Add("HUDPaint","FMHUD.Paint",function() FMHUD:Paint() end)


Remember to change ValidEntity to IsValid.

Ok so I scraped my custom version of the gamemode and started over from my base template.

I can now go into water! YAY!

I have two errors right now though

1.)



[ERROR] )'
  1. unknown - gamemodes/name/entities/weapons/gmod_tool/stool.lua:0



and

2.)



[ERROR] ...des/name/entities/weapons/gmod_tool/cl_viewscreen.lua:58: attempt to call method 'SetMaterialTexture' (a nil value)
  1. unknown - ...des/name/entities/weapons/gmod_tool/cl_viewscreen.lua:58



The first one seams to be a really weird error message and seams to have no effect on game play.
The second one has something to do with the tool gun. There are no tools (example: Weld)

IMaterial:SetMaterialTexture() is now IMaterial:SetTexture().

I fixed that now we just have



[ERROR] )'
  1. unknown - gamemodes/name/entities/weapons/gmod_tool/stool.lua:0





[ERROR] gamemodes/name/gamemode/cl_menu.lua:479: attempt to call method 'SetMultiple' (a nil value)
  1. AdminMenu - gamemodes/name/gamemode/cl_menu.lua:479
   2. Call - gamemodes/name/gamemode/cl_menu.lua:571
    3. unknown - gamemodes/base/gamemode/cl_spawnmenu.lua:66
     4. unknown - lua/includes/modules/concommand.lua:69


And the function for it



local function AdminMenu()
MENU.PlayerList = vgui.Create( "DComboBox")
MENU.PlayerList:SetParent( MENU.AdminBackground )
MENU.PlayerList:SetPos( 0, 0 )
MENU.PlayerList:SetSize( MENU.AdminBackground:GetWide()*.333, 225 )
MENU.PlayerList:SetMultiple( false ) // Don't use this unless you know extensive knowledge about tables
ResetPList()

MENU.Kick = vgui.Create( "DButton" )
MENU.Kick:SetParent( MENU.AdminBackground ) // Set parent to our "DermaPanel"
MENU.Kick:SetText("Kick")
MENU.Kick:SetPos( ((MENU.AdminBackground:GetWide()*.333) + 5), 0 )
MENU.Kick:SetSize( ((MENU.AdminBackground:GetWide()*.333) - 5), 50 )
	MENU.Kick.DoClick = function ()
		local Value = MENU.PlayerList:GetSelectedItems()[1]
		if Value != nil && Value != NULL && Value != "" then
			RunConsoleCommand("FM_Kick", Value:GetValue())
			local PlayerLeft = Value:GetValue()
			ResetPList(PlayerLeft)
		else
			print("No player selected!")
		end
	end 
	
	MENU.BanTime = vgui.Create("DListView")
	MENU.BanTime:SetParent( MENU.AdminBackground )
	MENU.BanTime:SetPos( ((MENU.AdminBackground:GetWide()*.666) + 5), 0 )
	MENU.BanTime:SetSize( ((MENU.AdminBackground:GetWide()*.333) - 5), 20 )
	MENU.BanTime:SetEditable(false)
	MENU.BanTime:AddChoice("5 Minutes")
	MENU.BanTime:AddChoice("15 Minutes")
	MENU.BanTime:AddChoice("30 Minutes")
	MENU.BanTime:AddChoice("1 Hour")
	MENU.BanTime:AddChoice("2 Hours")
	MENU.BanTime:AddChoice("6 Hours")
	MENU.BanTime:AddChoice("1 Day")
	MENU.BanTime:AddChoice("2 Days")
	MENU.BanTime:AddChoice("7 Days")
	MENU.BanTime:AddChoice("1 Month")
	MENU.BanTime:AddChoice("6 Months")
	MENU.BanTime:AddChoice("1 Year")
	MENU.BanTime:AddChoice("Forever")
	MENU.BanTime:ChooseOptionID(1)
	MENU.BanTime:SetEnabled(true)
	
MENU.Ban = vgui.Create( "DButton" )
MENU.Ban:SetParent( MENU.AdminBackground ) // Set parent to our "DermaPanel"
MENU.Ban:SetText("Ban")
MENU.Ban:SetPos( ((MENU.AdminBackground:GetWide()*.666) + 5), 25 )
MENU.Ban:SetSize( ((MENU.AdminBackground:GetWide()*.333) - 5), 25 )
	MENU.Ban.DoClick = function ()
		local Value = MENU.PlayerList:GetSelectedItems()[1]
		local Time = MENU.BanTime.TextEntry
		if Value != nil && Value != NULL && Value != "" then
			if Time != nil && Time != NULL && Time != "" then
				RunConsoleCommand("FM_Ban", Value:GetValue(), Time:GetValue())
				local PlayerLeft = Value:GetValue()
				ResetPList(PlayerLeft)
			else
				print("No time Specified")
			end
		else
			print("No player selected!")
		end
	end 
	
MENU.Slay = vgui.Create( "DButton" )
MENU.Slay:SetParent( MENU.AdminBackground ) // Set parent to our "DermaPanel"
MENU.Slay:SetText("Slay")
MENU.Slay:SetPos( ((MENU.AdminBackground:GetWide()*.333) + 5), 55 )
MENU.Slay:SetSize( ((MENU.AdminBackground:GetWide()*.333) - 5), 50 )
	MENU.Slay.DoClick = function ()
		local Value = MENU.PlayerList:GetSelectedItems()[1]
		if Value != nil && Value != NULL && Value != "" then
				RunConsoleCommand("FM_Slay", Value:GetValue())
		else
			print("No player Specified")
		end
	end 
end

function PlayerMenu()
MENU.HAHA = vgui.Create( "DButton" )
MENU.HAHA:SetParent( MENU.AdminBackground ) // Set parent to our "DermaPanel"
MENU.HAHA:SetText("you are not admin and can't view this page!")
MENU.HAHA:SetPos( 0, 0 )
MENU.HAHA:SetSize( MENU.AdminBackground:GetWide(), MENU.AdminBackground:GetTall() )
	MENU.HAHA.DoClick = function ()
		LocalPlayer():ConCommand("Ya sure you can have access")
	end
end


Also if I comment out the admin menu the tool menu does not work. There are no errors but no tools under constraints, construction, Posing, or Render.

The gamemode is all most fully operational

[editline]9th December 2012[/editline]

So I commented out
/MENU.PlayerList:SetMultiple( false ) // Don’t use this unless you know extensive knowledge about tables/
and
/MENU.BanTime:ChooseOptionID(1)/

Changed
MENU.BanTime:AddChoice
to
MENU.BanTime:AddLine

This is a screenshot of the menu

https://lh6.googleusercontent.com/9lFelXzmhcsRdmZp9cley4cEBtyMLKKjl__8XylhfI2x8Cc71FXSY1U_XQ4Z2P_wwLb4F0MLaLw

I uploaded what I have to garrysmod.org
http://www.garrysmod.org/downloads/?a=view&id=133188

You can follow along with me and help if you want.