HUD error

Hi, i was trying to make a HUD that shows the admins online. but i cant get the HUD to work :confused:


ShowAdmins = true

function toggleAdminList()
	if ShowAdmins then
		ShowAdmins = false
	else
		showAdmins = true
	end
end

toggleAdminList()

concommand.Add("show_admin", function()
	toggleAdminList()
end)

hook.Add("HUDPaint", "toggleAdminList", function()
	if ShowAdmins then
		for k, v in pairs(player.GetAll()) do
			if v:IsAdmin() or v:IsSuperAdmin() then
					adminList = adminList .. ", " .. v:Nick() // use .. to concat strings
			end
		end
			
		
			if (adminList != "") then
				adminList = string.sub(adminList, 3, string.len(adminList))
				draw.SimpleText("Admins: "..adminList, ScrW() * 0.8, ScrH() * 0.2, Color(0, 255, 0, 200), 1, 1)
			else
				draw.SimpleText("No admins online!", ScrW() * 0.8, ScrH() * 0.2, Color(255, 0, 0, 200), 1, 1)
			end
		end)
	end)

When you post Lua, place it in a lua tag instead of a code tag.

You did not have a font set in your draw.SimpleText calls. I also cleaned up your code a bit:
[lua]local showAdmins = true
concommand.Add(“show_admin”, function()
if showAdmins then
showAdmins = false
else
showAdmins = true
end
end
)
hook.Add(“HUDPaint”, “AdminList”, function()
if showAdmins then
local adminList = “”
for _,v in pairs(player.GetAll()) do
if v:IsAdmin() or v:IsSuperAdmin() then
adminList = adminList…", "…v:Nick()
end
end
if adminList ~= “” then
adminList = string.sub(adminList, 3, string.len(adminList))
draw.SimpleText("Admins: "…adminList, “ScoreboardText”, ScrW()*0.8, ScrH()*0.2, Color(0,255,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
else
draw.SimpleText(“No admins online!”, “ScoreboardText”, ScrW()*0.8, ScrH()*0.2, Color(255,0,0,200), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
end
end
)[/lua]

Thanks! As you can see its my first time posting here, and I guess I should have read the sticky :expressionless:

HUD is clientside. From what I know, the only player you can get from the client is the client himself. You’ll want to send some usermessages or datastream the info.

Other players exist on the client…

**[player.GetByID(id)

http://wiki.garrysmod.com/images/0/0d/NewerShared.png](http://wiki.garrysmod.com/?title=Player.GetByID)**

Oh shit, I never knew this.

But yeah, I’m just returning (I haven’t really played GMod since 08 or 09…) to Lua scripting. So there’s a lot of new shit I don’t know about. Back when I was scripting, this kinda shit always fucked up on me.