Gmod ingame player list "hud"

Hey!

Does anyone know how these some guys make “hud” in the map where are listed names, pings, and server name?

I know some lua, i just want to understand how to start doing it, where to put the files, possibly i think to autorun/server.

So the “hud” is in map placeable thing which you can put to wall as a example, and you can see little bit through it, and there are names, like scoreboard but in world so you dont have to press “TAB” key.

Thank you!

It’s using a mix of 3D2D and the draw library.

You position where the text appears in the world with the arguments in cam.Start3D2D, and then just use the draw library as if it were on the HUD.

[img_thumb]http://puu.sh/8hl9m.jpg[/img_thumb]
[lua]
–[[-----------------------------------------------------------
Here’s a small example I just made to help you get started.

This is the cl_init of a entity, you could hook into other
rendering methods to draw a floating hud in the world.
But I like using entities because you can drag them arround
when finding a place to put the 3d2d.

This is all handled client side so I shouldn't need to
paste the init.lua of my example entity.

Happy coding

–]]-----------------------------------------------------------

function ENT:Draw()
self.Entity:DrawModel()

if LocalPlayer():EyePos( ):Distance(self.Entity:GetPos()) > 1000 then return end -- don't render if player is far away

-- Example of adding dynamics to it, background fades in as you get closer
local FadeAlpha = math.Clamp(500 - LocalPlayer():EyePos( ):Distance(self.Entity:GetPos())/2, 0 , 150)


local ang = self.Entity:GetAngles()
local pos = self.Entity:GetPos() 

local drawang = self.Entity:GetAngles()
drawang:RotateAroundAxis(self.Entity:GetAngles():Forward(), 90) -- set up rotation for rendering

cam.Start3D2D(pos + ang:Up()*75, drawang, 0.20)
	
	--Background
		surface.SetDrawColor(128, 255, 0, FadeAlpha )
	surface.DrawRect(-295, -195, 590, 390)

	--Dark Lines
	surface.SetDrawColor( 50, 50, 50, 255 )
   		surface.DrawRect(-300, -200, 400, 10)
   		surface.DrawRect(-300, -200, 10, 100)
   		surface.DrawRect(290, 200, 10, -100)
   		surface.DrawRect(290, 190, -400, 10)

   	--Player List (up to 24 names)
   	for k,v in pairs(player.GetAll()) do
   		local offset = -275
   		local rowreset = 0
   		if k > 24 then break elseif k > 12 then offset = 20 rowreset = 12 end
		draw.DrawText( v:Nick(), "DermaLarge", offset, -215 +(k-rowreset)*30, Color(0, 162, 232, 255), TEXT_ALIGN_LEFT )
		draw.DrawText( v:Ping(), "DermaLarge", offset+200, -215 +(k-rowreset)*30, Color(0, 162, 232, 255), TEXT_ALIGN_LEFT )
	end

cam.End3D2D() 

-- surface.DrawRect render stuff on both sides
-- draw.DrawText Does not so we need to render the names on the other side

drawang:RotateAroundAxis(self.Entity:GetAngles():Up(), 180) --Rotate to render text on other side
cam.Start3D2D(pos + ang:Up()*75, drawang, 0.20)
   	--Player List (up to 24 names) same stuff as above
   	for k,v in pairs(player.GetAll()) do
   		local offset = -275
   		local rowreset = 0
   		if k > 24 then break elseif k > 12 then offset = 20 rowreset = 12 end
		draw.DrawText( v:Nick(), "DermaLarge", offset, -215 +(k-rowreset)*30, Color(0, 162, 232, 255), TEXT_ALIGN_LEFT )
		draw.DrawText( v:Ping(), "DermaLarge", offset+200, -215 +(k-rowreset)*30, Color(0, 162, 232, 255), TEXT_ALIGN_LEFT )
	end
cam.End3D2D() 

end

[/lua]

Thank you very much, but where do i put this if not in entities? Like world prop/or just giving pos for it.
Very much thanks for you, for giving example, will start coding when i know where to put it.

Anyone knows where to put? Lua/autorun/client?

Its a cl_init of an entity, make an entity and put that code in the cl_init.

I know, but i dont want entity… i just want that when i restart the server, it is there not prop/entity that has to be spawned.

Then spawn that entity as soon as the server runs? ( using Lua, of course )

One way, but the entity sitting somewhere in map… Cmoon there haves to be no entity way.

If i dont use entity, how i can change the LocalPlayer?