Removing Spawn menu

Im making a gamemode and I have a question, how can i remove the Spawn Menu?? If I remove it, can people even spawn props?? I have all these question that id like to know…

Thank you to all the people that will help me.

You can disable the spawn menu with the “OnSpawnMenuOpen” hook.
[lua]
function GM:OnSpawnMenuOpen() return; end;
[/lua]
Untested but should work.

You can also do something like this:
[lua]
function GM:OnSpawnMenuOpen()
RunConsoleCommand(“OpenNewSpawnMenu”)
end;
[/lua]
Again, untested but it should make the client run the console command “OpenNewSpawnMenu” which, if created, might open a custom spawn menu.

To make the client spawn things, you can use "RunConsoleCommand(“gm_spawn”, “<model path here>”)

If you want to disable spawning completely then, if you gamemode is sandbox derived, you can use this:
[lua]
function GM:SpawnProp(ply, model)
return false
end
[/lua]

To make spawning props admin only, use this:
[lua]
function GM:SpawnProp(ply, model)
return ply:IsAdmin()
end
[/lua]

Hope I helped!

The safest way to go about it would be to derive your gamemode from ‘base’ instead of ‘sandbox’. That way all sandbox functions such as spawning and tools are completely unaccessible. Just make sure you use entities that derive from the base gamemode entities, not from the sandbox entities.

And when you give weapon, what is the name of the grav gun?? I tested weapon_gravgun, but it dosent work.

Also, for my HUD, I can only make health but i dont know how to make armor, look at the code:

function GM:HUDPaint(Health)

self.BaseClass:HUDPaint(Health)

local person = LocalPlayer() 

local Health = LocalPlayer():Health()

surface.CreateFont("coolvertica",64,400,false,false,"douchebag")

surface.SetTextColor( 255, 0, 0, 255 )
surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4))
surface.SetFont("douchebag")
surface.DrawText( Health)

end

Why that would be LocalPlayer():Armor() :wink:

For everything non lua I suggest you refer to the Valve Developer Community : http://developer.valvesoftware.com/wiki/Main_Page

The name of the gravity gun is weapon_physcannon.
http://developer.valvesoftware.com/wiki/Gravity_gun

[editline]01:45PM[/editline]

Also for more readability I suggest you place your code inside [lua] or


 tags in the future. :smile:

[lua]function GM:HUDPaint(Health)

	self.BaseClass:HUDPaint(Health)
	
	local person = LocalPlayer() 
	
	local Health = LocalPlayer():Health()
	
	surface.CreateFont("coolvertica",64,400,false,false,"douchebag")
	
	surface.SetTextColor( 255, 0, 0, 255 )
	surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4))
	surface.SetFont("douchebag")
	surface.DrawText( Health)
end[/lua]

I dont understand your LocalPlayer():Armor() thing…

P.S : I think your from quebec?? Me too :slight_smile:

Just as in your script you used LocalPlayer():Health() to get the health of a player, use LocalPlayer():Armor() to get their Armor. LocalPlayer() is what you usually use to get the client’s player object.


function GM:HUDPaint(Armor)

	self.BaseClass:HUDPaint(Armor)
	
	local person = LocalPlayer() 
	
	local Health = LocalPlayer():Armor()
	
	surface.CreateFont("coolvertica",64,400,false,false,"douchebag")
	
	surface.SetTextColor( 255, 0, 0, 255 )
	surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4))
	surface.SetFont("douchebag")
	surface.DrawText( Armor)
end

So i need to do that??

How can I change the place without changing the Health code??

Pretty much, tough I suggest you change the position of the text so they don’t overlap. :wink:

oh you mentioned it. Well you would just modify the SetTextPos parameters.

surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4))

to

surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4 - 32)) or something. Your’s to decide really.

[editline]04:36PM[/editline]

Also use this, much simpler :
[lua]
surface.SetTextPos(34, ScrH() * 0.75)) --Health

surface.SetTextPos(34, ScrH() * 0.75 - 32)) --Armor
[/lua]

So the code should look like this??:


function GM:HUDPaint(Health)

	self.BaseClass:HUDPaint(Health)
	
	draw.DrawText("You are playing GmDeathmatch by Bilbasio.", "ScoreboardText", ScrW() / 2 - 70, ScrH() - 63, Color(255,255,255,255),1)

	local person = LocalPlayer() 
	
	local Health = LocalPlayer():Health()
	
	surface.CreateFont("coolhealth",64,400,false,false,"playerhealth")
	
	surface.SetTextColor( 255, 0, 0, 255 )
	surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4))
	surface.SetFont("playerhealth")
	surface.DrawText( Health)
end

function GM:HUDPaint(Armor)

	self.BaseClass:HUDPaint(Armor)
	
	local person = LocalPlayer() 
	
	local Health = LocalPlayer():Armor()
	
	surface.CreateFont("coolarmor",64,400,false,false,"playerarmor")
	
	surface.SetTextColor( 255, 0, 0, 255 )
	surface.SetTextPos(34, (ScrH()/2)+(ScrH()/4-32))
	surface.SetFont("playerarmor")
	surface.DrawText( Armor)
end

Oh, no. :slight_smile: You can only have one of these in the GM: format. Here :

[lua]function GM:HUDPaint()

draw.DrawText("You are playing GmDeathmatch by Bilbasio.", "ScoreboardText", ScrW() / 2 - 70, ScrH() - 63, Color(255,255,255,255),1)

local person = LocalPlayer() 

local Health = LocalPlayer():Health()

surface.CreateFont("coolhealth",64,400,false,false,"playerhealth")

surface.SetTextColor( 255, 0, 0, 255 )
surface.SetTextPos(34, (34, ScrH() * 0.75))
surface.SetFont("playerhealth")
surface.DrawText( Health)


local Armor= LocalPlayer():Armor()

surface.CreateFont("coolarmor",64,400,false,false,"playerarmor")

surface.SetTextColor( 255, 0, 0, 255 )
surface.SetTextPos(34, (34, ScrH() * 0.75)32)
surface.SetFont("playerarmor")
surface.DrawText( Armor)

end[/lua]

Also I’m not quite sure your fonts will work. Unless you really have them installed.

Hummm… It is not working.

Of course not, because I had stupidly left an end in the middle. But that’s the kind of things you should be able to figure out yourself. If you don’t already I suggest you use Notepad++ with a good gmod lua syntax highlighting plugin. It will make these petty problems a thing of the past.

edit : You also had extra brackets a bit everywhere. And I’m still sure that font won’t magically work on it’s own.

Can you suggest me a plugin??

That one : http://www.facepunch.com/showthread.php?t=477505