Today, I'd like to ask a question about HUD. So, I have a HUD uploaded to workshop here
I was trying to make update of it, make information over players head. I made it, but other players see it only above themselves, no info about other players, how do I make it server sided so everyone can see it?
Code:
local function DrawPlayersInfo()
local pos = ply:EyePos()
pos.z = pos.z + 30 -- The position we want is a bit above the position of the eyes
pos = pos:ToScreen()
if GAMEMODE.Config.showname and ply:Alive() then
local name = ply:Name()
local teamcol = ply:Team()
local health = ply:Health()
local plyhealth = Color(255,255,255)
if health <= 80 then
plyhealth = Color(255, 216, 216)
end
if health <= 60 then
plyhealth = Color(255, 161, 161)
end
if health <= 40 then
plyhealth = Color(255, 117, 117)
end
if health <= 20 then
plyhealth = Color(255, 81, 81)
end
if health <= 0 then
plyhealth = Color(255, 0, 0)
end
draw.SimpleText(name, "Playerfont", pos.x, pos.y + 20, plyhealth, TEXT_ALIGN_CENTER)
end
if GAMEMODE.Config.showjob and ply:Alive() then
local teamname = ply:getDarkRPVar("job") or team.GetName(ply:Team())
draw.SimpleText(teamname, "Playerfont", pos.x , pos.y + 50, RPExtraTeams[ply:Team()].color or team.GetColor(ply:Team()), TEXT_ALIGN_CENTER)
end
if ply:getDarkRPVar("HasGunlicense") and ply:Alive() then
local licenceimghead = Material("erluxhud/gunlicence.png")
surface.SetMaterial(licenceimghead)
surface.SetDrawColor(255,255,255,255)
surface.DrawTexturedRect(pos.x-10, pos.y + 75, 32, 32)
end
if ply:getDarkRPVar("wanted") and ply:Alive() then
draw.SimpleText("Wanted!", "Warningfont", pos.x, pos.y - 30, Color(255,0,0), TEXT_ALIGN_CENTER)
end
if GetGlobalBool("DarkRP_LockDown") then
R = math.random(0,255)
draw.SimpleText("Lockdown has began!", "Warningfont", 100, 0, Color(R, 0, 0))
end
end
hook.Add("HUDPaint", "PlayersInfo", DrawPlayersInfo)
Better code: hastebin
Loop through all players in the hook and draw it for each one.
like
for k,v in pairs( player.GetAll() ) do
draw.SimpleText("lmao", "randomfont, 0, 0, Color(255,255,255))
end
yeah?
do you mean with "make information over players head" that it hovers over their heads? because if yes your loop wont do it.
Yeah, information above players head like name and job
Do you get any Script Error or Feedback from your Addon?
Sure, but you will need to change the position of the text for each loop iteration so the names don't draw on top of each other.
Nope, it just doesn't show on other players only on local player
the problem is, your title says "server side hud". thats not possible.
a hud cant be serverside, cause a server is not a player and has no screen.
a hud is always clientside. also if the hud works on local player, then whats the problem?
If people have the addon/hud subscribed it works for all of them, and youre good to go.
I'm gonna check about subscriptions.
no what i mean is, a HUD is always clientside, if you upload your addon, which works for localplayer, to the workshop, and then put the addon in the servers addon collcetion so the server has it, every player that joins shoulöd download it automatically and it should work for everyone. easy as that
Your hook is just declaring a function that's never called. Look up other HUDs (like the default one) to know how they do it.
Sorry, you need to Log In to post a reply to this thread.