Hello i am creating a Undercover job and i want text above the players head that is using the job "Undercover" this is what i have so far only simple.
[CODE]function DrawUndercoverIndicator(ply)
local zOffset = 50
local x = ply:GetPos().x
local y = ply:GetPos().y
local z = ply:GetPos().z
local pos = Vector(x,y,z+zOffset)
local pos2d = pos:ToScreen()
draw.DrawText("Undercover","Default",pos2d.x,pos2d.y,Color(25, 25, 170, 255),TEXT_ALIGN_CENTER)
end
function LoopThroughPlayers()
for k,v in(player.GetAll()) do
if ply:Team() == allowedTeam then // This is Team Undercover
DrawUndercoverIndicator(v)
end
end
end
hook.Add("HUDPaint", "LoopThroughPlayers", LoopThroughPlayers)[/CODE]
how do i make it so the text only apears for a list of allowed teams for example. :ohno:
Thanks guys sorry for probably poor coding
[CODE]
local allowed_teams = {
SOME_TEAM = true,
ANOTHER_TEAM = true,
YOU_GET_THE_IDEA = true,
}
local function LoopThroughPlayers()
for k,v in(player.GetAll()) do
if allowed_teams[ ply:Team() ] then // This is Team Undercover
DrawUndercoverIndicator(v)
end
end
end
[/CODE]
Also, your code is alright but please make your functions local
[editline]25th August 2016[/editline]
Also, this:
[CODE]
function DrawUndercoverIndicator(ply)
local zOffset = 50
local x = ply:GetPos().x
local y = ply:GetPos().y
local z = ply:GetPos().z
local pos = Vector(x,y,z+zOffset)
local pos2d = pos:ToScreen()
draw.DrawText("Undercover","Default",pos2d.x,pos2d.y,Color(25, 25, 170, 255),TEXT_ALIGN_CENTER)
end
[/CODE]
Can be simplified into this:
[CODE]
function DrawUndercoverIndicator(ply)
local zOffset = 50
local pos = ply:GetPos()
pos.z = pos.z + zOffset
local pos2d = pos:ToScreen()
draw.DrawText("Undercover","Default",pos2d.x,pos2d.y,Color(25, 25, 170, 255),TEXT_ALIGN_CENTER)
end
[/CODE]
Sorry, you need to Log In to post a reply to this thread.