cl_init

Im not having a problem initializing the file according to the console, but in my gamemode the hud and etc gives me this error : [ERROR] gamemodes/battleroyale/gamemode/cl_init.lua:121: attempt to call method ‘Alive’ (a nil value)
, and onyl way to get rid of it is to re-save the file during runtime. Anyone know what would cause this…?

How are we meant to point you to the line and tell you what the hell is wrong - when you haven’t provided any code at all?

@Edit: Altho symptome seems like you are applying a variable to localplayer before he loads.


	GM.Version = "0.0.1"
	GM.Name = "Battle Royale"
	GM.Author = "Damien Ostler | 336-823-0423 | Damienostler1@outlook.com"
DeriveGamemode("base" ) 
	include("cl_commandsystem.lua")	

	client=LocalPlayer()

	local armormat = Material ("battleroyale/armor2.png", "nocull")
	local barfillmat = Material ("battleroyale/barFill.png", "nocull")
	local barmarkermat = Material ("battleroyale/barMarker.png", "nocull")
	local barbackgroundmat = Material ("battleroyale/barBackground.png", "nocull")
	local healthmat = Material ("battleroyale/health2.png", "nocull")
	local playerportraitmat = Material ("battleroyale/playerPortrait.png", "nocull")
	local crosshairmat = Material ("battleroyale/crosshair.png", "nocull")
	local honeycomb	mat = Material ("battleroyale/honeyComb.png", "nocull")
	local CrosshairRadius = 25
	local CrosshairColor = Color( 0, 0, 0, 255 )

	surface.CreateFont( "HudFont1", {
		font = "Tele-Marines", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
		size = 20,
		weight = 100,
		blursize = 0,
		scanlines = 0,
		antialias = true,
		underline = false,
		italic = false,
		strikeout = false,
		symbol = false,
		rotary = false,
		shadow = false,
		additive = false,
		outline = false,
	} )

	surface.CreateFont( "HudFont2", {
		font = "Tele-Marines", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
		size = 14,
		weight = 100,
		blursize = 0,
		scanlines = 0,
		antialias = true,
		underline = false,
		italic = false,
		strikeout = false,
		symbol = false,
		rotary = false,
		shadow = false,
		additive = false,
		outline = false,
	} )
	surface.CreateFont( "HudTimer", {
		font = "Tele-Marines", -- Use the font-name which is shown to you by your operating system Font Viewer, not the file name
		size = 30,
		weight = 100,
		blursize = 0,
		scanlines = 0,
		antialias = true,
		underline = false,
		italic = false,
		strikeout = false,
		symbol = false,
		rotary = false,
		shadow = false,
		additive = false,
		outline = false,
	} )

	local hide = {
		CHudAmmo = true,
		CHudBattery = true,
		CHudCrosshair = true,
		CHudHealth = true,
		CHudSecondaryAmmo = true,
		--CHudWeaponSelection = true
	}


if not ConVarExists("cl_covercamera") then
    CreateClientConVar("cl_covercamera", '1', true)
end

if not ConVarExists("cl_covertext") then
    CreateClientConVar("cl_covertext", '1', true)
end

if not ConVarExists("cl_coverauto") then
    CreateClientConVar("cl_coverauto", '0', true)
end



timevar=string.ToMinutesSeconds(0)

net.Receive( "updateTimer", function( len, pl )
timervar=net.ReadString()
end)










	hook.Add( "HUDShouldDraw", "HideHUD", function( name )
		if ( hide[ name ] ) then return false end
	end )

	function HUDPaint()

	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( armormat	) -- If you use Material, cache it!
	surface.DrawTexturedRect(  (ScrW()/2)-150,25, 300,  75 )
	local w,h = draw.SimpleTextOutlined( timervar, "HudTimer", 900*( ScrW() / 1920),60*( ScrH() / 1080),Color(152,218,217),0,0,0.5,Color(150,150,150) )


	if(client:Alive() && client:GetNWBool("inGame"))then


	--Player Portiat--
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( playerportraitmat		) -- If you use Material, cache it!
	surface.DrawTexturedRect(  25*( ScrW() / 1920),25*( ScrH() / 1080), 200*( ScrW() / 1920)	,  200*( ScrH() / 1080)	 )
	------------------

	--Armor Bar--
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barbackgroundmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect(  200*( ScrW() / 1920),88*( ScrH() / 1080), 200*( ScrW() / 1920),  49*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barfillmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 200*( ScrW() / 1920), 76*( ScrH() / 1080), ((200/client:GetNWInt("maxArmor"))*client:Armor())*( ScrW() / 1920), 75*( ScrH() / 1080) )
	surface.SetMaterial( barmarkermat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 190*( ScrW() / 1920),93*( ScrH() / 1080), 35*( ScrW() / 1920),  35*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )


	surface.SetMaterial( armormat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 198*( ScrW() / 1920),65*( ScrH() / 1080), 200*( ScrW() / 1920),  45*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )

	if(client:Armor()>client:GetNWInt("maxArmor")/2)then
		local w,h = draw.SimpleTextOutlined( "Armor", "HudFont1", 245*( ScrW() / 1920),70*( ScrH() / 1080),Color(152,218,217),0,0,0.5,Color(150,150,150) )
	elseif(client:Armor()>client:GetNWInt("maxArmor")/3)then
		local w,h = draw.SimpleTextOutlined( "Armor", "HudFont1", 245*( ScrW() / 1920),70*( ScrH() / 1080),Color(225,225,0),0,0,0.5,Color(150,150,150) )
	else
		local w,h = draw.SimpleTextOutlined( "Armor", "HudFont1", 245*( ScrW() / 1920),70*( ScrH() / 1080),Color(152,0,0),0,0,0.5,Color(150,150,150) )
	end
	------------
	--------------

	--Health Bar--
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barbackgroundmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect(  250*( ScrW() / 1920),168*( ScrH() / 1080), 200*( ScrW() / 1920),  49*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barfillmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 250*( ScrW() / 1920), 156*( ScrH() / 1080), ((200/client:GetMaxHealth())*client:Health())*( ScrW() / 1920), 75*( ScrH() / 1080)	 )
	surface.SetMaterial( barmarkermat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 240*( ScrW() / 1920),173*( ScrH() / 1080), 35*( ScrW() / 1920),  35*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )


	surface.SetMaterial( armormat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 220*( ScrW() / 1920),145*( ScrH() / 1080), 240*( ScrW() / 1920),  45*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )

	if(client:Health()>client:GetMaxHealth()/2)then
		local w,h = draw.SimpleTextOutlined( "Health", "HudFont1", 285*( ScrW() / 1920),150*( ScrH() / 1080),Color(152,218,217),0,0,0.5,Color(150,150,150) )
	elseif(client:Health()>client:GetMaxHealth()/3)then
		local w,h = draw.SimpleTextOutlined( "Health", "HudFont1", 285*( ScrW() / 1920),150*( ScrH() / 1080),Color(225,225,0),0,0,0.5,Color(150,150,150) )
	else
		local w,h = draw.SimpleTextOutlined( "Health", "HudFont1", 285*( ScrW() / 1920),150*( ScrH() / 1080),Color(152,0,0),0,0,0.5,Color(150,150,150) )
	end
	------------
	------------



	--Health Bar--
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barbackgroundmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect(  50*( ScrW() / 1920),238*( ScrH() / 1080), 400*( ScrW() / 1920),  49*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( barfillmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 50*( ScrW() / 1920), 226*( ScrH() / 1080), ((400/client:GetNWInt("maxStamina"))*client:GetNWInt("curStamina"))*( ScrW() / 1920), 75*( ScrH() / 1080) )
	surface.SetMaterial( barmarkermat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 40*( ScrW() / 1920),243*( ScrH() / 1080), 35*( ScrW() / 1920),  35*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )


	surface.SetMaterial( armormat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( 125*( ScrW() / 1920),215*( ScrH() / 1080), 240*( ScrW() / 1920),  45*( ScrH() / 1080) )
	surface.SetDrawColor( 255, 255, 255, 255 )
	if(client:GetNWInt("curStamina")>client:GetNWInt("maxStamina")/2)then
		local w,h = draw.SimpleTextOutlined( "Energy", "HudFont1", 175*( ScrW() / 1920),220*( ScrH() / 1080),Color(152,218,217),0,0,0.5,Color(150,150,150) )
	elseif(client:GetNWInt("curStamina")>client:GetNWInt("maxStamina")/3)then
		local w,h = draw.SimpleTextOutlined( "Energy", "HudFont1", 175*( ScrW() / 1920),220*( ScrH() / 1080),Color(225,225,0),0,0,0.5,Color(150,150,150) )
	else
		local w,h = draw.SimpleTextOutlined( "Energy", "HudFont1", 175*( ScrW() / 1920),220*( ScrH() / 1080),Color(152,0,0),0,0,0.5,Color(150,150,150) )
	end
	------------



	--Crosshair--
	surface.SetDrawColor( CrosshairColor )
	surface.SetMaterial( crosshairmat	) -- If you use Material, cache it!
	surface.DrawTexturedRect( ScrW() / 2-CrosshairRadius, ScrH() / 2-CrosshairRadius, CrosshairRadius, CrosshairRadius  )
	-------------

	--Ammo Area--

	surface.SetDrawColor( 255, 255, 255, 255 )
	surface.SetMaterial( armormat	) -- If you use Material, cache it!
	surface.DrawTexturedRect(  ScrW()-380,ScrH()-130, 400,  150 )

	local w,h = draw.SimpleTextOutlined( "Ammo", "HudFont1", ScrW()-290,ScrH()-90,Color(152,218,217),0,0,0.5,Color(150,150,150) )
	local mag_left = client:GetActiveWeapon():Clip1() // How much ammunition you have inside the current magazine
	local mag_extra = client:GetAmmoCount(client:GetActiveWeapon():GetPrimaryAmmoType()) // How much ammunition you have outside the current magazine
	local secondary_ammo = client:GetAmmoCount(client:GetActiveWeapon():GetSecondaryAmmoType())
	local w,h = draw.SimpleTextOutlined( mag_left.." || "..mag_extra, "HudFont1", ScrW()-290,ScrH()-50,Color(152,218,217),0,0,0.5,Color(150,150,150) )
	local w,h = draw.SimpleTextOutlined( secondary_ammo, "HudFont1", ScrW()-120,ScrH()-65,Color(152,218,217),0,0,0.5,Color(150,150,150) )
	local w,h = draw.SimpleTextOutlined( "Seconary", "HudFont2", ScrW()-155,ScrH()-85,Color(152,218,217),0,0,0.5,Color(150,150,150) )
	-------------





	ply = LocalPlayer()
	if GetConVarNumber("cl_coverauto") == 1 then
	return
	end
	if GetConVarNumber("cl_covertext") == 0 then
	return
	end
	--English--
	if (GetConVarNumber("cl_covertext") == 1) then
	if not(ply:GetNWBool("cover")) then
						tracedata={}
	tracedata.start = ply:EyePos() + (ply:GetForward() * 1)
	tracedata.endpos = ply:EyePos() + (ply:GetForward() * 64)
	tracedata.filter = ply
	local trace = util.TraceLine(tracedata)
	if trace.Hit then

		surface.SetFont("CoverFont")
		local message = "Press *ALT* to get in of cover."
		local width, height = surface.GetTextSize( message )

		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( armormat	) -- If you use Material, cache it!
		surface.DrawTexturedRect(  ((ScrW() / 2)-650)*( ScrW() / 1600),(ScrH()-240)*( ScrH() / 900),1200*( ScrW() / 1600),  200*( ScrH() / 900) )

		draw.DrawText( "Press *ALT* to get in cover.", "CoverFont",(ScrW() / 2)-(width/2) , ScrH()-150, Color( 152,218,217) )

		--draw.DrawText( "ALT", "CoverKeyFont", ScrW() / 2, ScrH() - 153, Color( 255, 255, 0 ) )
	end
	end
	if (ply:GetNWBool("cover")) then
						tracedata={}
	tracedata.start = ply:EyePos() + (ply:GetForward() * 1)
	tracedata.endpos = ply:EyePos() + (ply:GetForward() * 64)
	tracedata.filter = ply
	local trace = util.TraceLine(tracedata)
	if (trace.Hit) then
		surface.SetFont("CoverFont")
		local message = "Press *ALT* to get out of cover."
		local width, height = surface.GetTextSize( message )

		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( armormat	) -- If you use Material, cache it!
		surface.DrawTexturedRect(  ((ScrW() / 2)-650)*( ScrW() / 1600),(ScrH()-240)*( ScrH() / 900),1200*( ScrW() / 1600),  200*( ScrH() / 900) )

		draw.DrawText( "Press *ALT* to get out of cover.", "CoverFont", (ScrW() / 2)-(width/2) , ScrH()-150, Color( 152,218,217) )
		--draw.DrawText( "ALT", "CoverKeyFont", ScrW() / 2-50, ScrH() - 153, Color( 255, 255, 0 ) )
	end
	end
	if (ply:GetNWBool("cover")) then
	tracedata={}
		tracedata.start = ply:EyePos() + (ply:GetRight() * 33) + (ply:GetForward() * 1)
		tracedata.endpos = ply:EyePos()+ (ply:GetRight() * 34) + (ply:GetForward() * 64)
		tracedata.filter = ply
		local trace = util.TraceLine(tracedata)
		if not (trace.Hit) then

		surface.SetFont("CoverFont")
		local message = "Hold *D* to peek."
		local width, height = surface.GetTextSize( message )

		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( armormat	) -- If you use Material, cache it!
		surface.DrawTexturedRect(  ((ScrW() / 2)-650)*( ScrW() / 1600),(ScrH()-170)*( ScrH() / 900),1200*( ScrW() / 1600),  200*( ScrH() / 900) )

		draw.DrawText( "Hold *D* to peek.", "CoverFont", (ScrW() / 2)-(width/2) , ScrH()-100, Color( 152,218,217) )
		--draw.DrawText( "D", "CoverKeyFont", ScrW() / 2 + 135, ScrH() - 133, Color( 255, 255, 0 ) )
	end
	end
	if (ply:GetNWBool("cover")) then
	tracedata={}
		tracedata.start = ply:EyePos() + (ply:GetRight() * -33) + (ply:GetForward() * 1)
		tracedata.endpos = ply:EyePos()+ (ply:GetRight() * -34) + (ply:GetForward() * 64)
		tracedata.filter = ply
		local trace = util.TraceLine(tracedata)
		if not (trace.Hit) then
		surface.SetFont("CoverFont")
		local message = "Hold *A* to peek."
		local width, height = surface.GetTextSize( message )

		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( armormat	) -- If you use Material, cache it!
		surface.DrawTexturedRect(  ((ScrW() / 2)-650)*( ScrW() / 1600),(ScrH()-170)*( ScrH() / 900),1200*( ScrW() / 1600),  200*( ScrH() / 900) )

		draw.DrawText( "Hold *A* to peek.", "CoverFont", (ScrW() / 2)-(width/2) , ScrH()-100, Color( 152,218,217) )
		--draw.DrawText( "A", "CoverKeyFont", ScrW() / 2 - 40, ScrH() - 133, Color( 255, 255, 0 ) )
	end
	end
	if (ply:GetNWBool("cover")) then
	if( ply:Crouching() ) then
		tracedata.start = ply:EyePos() + (ply:GetUp() * 38) + (ply:GetForward() * 1)
		tracedata.endpos = ply:EyePos()+ (ply:GetUp() * 50) + (ply:GetForward() * 64)
		tracedata.filter = ply
		local trace = util.TraceLine(tracedata)
		if (trace.Hit) then

		surface.SetFont("CoverFont")
		local message = "Hold *ALT* to stand up."
		local width, height = surface.GetTextSize( message )

		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial( armormat	) -- If you use Material, cache it!
		surface.DrawTexturedRect(  ((ScrW() / 2)-650)*( ScrW() / 1600),(ScrH()-240)*( ScrH() / 900),1200*( ScrW() / 1600),  200*( ScrH() / 900) )

		draw.DrawText( "Press *ALT* to stand up.", "CoverFont", (ScrW() / 2)-(width/2) , ScrH()-100, Color( 152,218,217) )
		--draw.DrawText( "SHIFT", "CoverKeyFont", ScrW() / 2 - 25, ScrH() - 113, Color( 255, 255, 0 ) )
		end
		if not (trace.Hit) then
--[[
		surface.SetFont("CoverFont")
		local message = "Hold *SHIFT* to peek."
		local width, height = surface.GetTextSize( message )
		draw.DrawText( "Hold *SHIFT* to peek.", "CoverFont", (ScrW() / 2)-(width/2) , ScrH()-100, Color( 152,218,217) )
		--draw.DrawText( "SHIFT", "CoverKeyFont", ScrW() / 2 - 25, ScrH() - 113, Color( 255, 255, 0 ) )]]
		end
	end
	end
	end
	--English End--
	
	end
	end
	hook.Add( "HUDPaint", "PaintOurHud", HUDPaint );







If you are going to give us the entire file post it on paste bin so it at least has line numbers.

Did you not read Neth’s post?

client=LocalPlayer()

‘Altho symptome seems like you are applying a variable to localplayer before he loads.’

IIRC LocalPlayer() returns nil until after InitPostEntity is called, so you’ll have to wait until that hook is called to assign/do anything with LocalPlayer().

I went to bed but yeah, was gonna say i found out i was assignning the variable “client” before LocalPlayer() could be called. It works perfectly now :slight_smile: