• Distance between the players for overhead HUD
    3 replies, posted
Hello, so I have an overhead thing I'm testing below, but I'm wondering how I'd make it so that the overhead only shows if the player is x distance from the player: local function CR_Above(ply)     local zOffset = 80     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()     surface.SetFont( "CR_HUDFontAgendaTitle" )     local width = surface.GetTextSize( ply:Nick() )     draw.RoundedBox( 0, pos2d.x - width / 2 - 10, pos2d.y - 50, width + 20, 30, Color( 0, 0, 0, 200 ) )     surface.SetFont( "CR_HUDFontAgendaTitle" )     local width = surface.GetTextSize( ply:getDarkRPVar("job") )     draw.RoundedBox( 0, pos2d.x - width / 2 - 10, pos2d.y - 10, width + 20, 30, Color( 0, 0, 0, 200 ) )     surface.SetFont( "CR_HUDFontAgendaTitle" )     local width = surface.GetTextSize( TranslateGroup( ply:GetUserGroup(), false ) )     draw.RoundedBox( 0, pos2d.x - width / 2 - 10, pos2d.y + 30, width + 20, 30, Color( 0, 0, 0, 200 ) )     draw.DrawText( ply:Nick(), "CR_HUDFontAgendaTitle", pos2d.x, pos2d.y - 50 + 3, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )     draw.DrawText( ply:getDarkRPVar("job"), "CR_HUDFontAgendaTitle", pos2d.x, pos2d.y - 10 + 3, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER )     draw.DrawText( TranslateGroup( ply:GetUserGroup(), false ), "CR_HUDFontAgendaTitle", pos2d.x, pos2d.y + 30 + 3, Color( 255, 255, 255 ), TEXT_ALIGN_CENTER ) end
if(self:GetPos():Distance(LocalPlayer():GetPos()) > 100000) then return end (Not checked)
Use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/DistToSqr]Vector:DistToSqr[/url], not [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Vector/Distance]Vector:Distance[/url].
if LocalPlayer():GetPos():DistToSqr(self:GetPos()) <= 250000 then --500^2
Sorry, you need to Log In to post a reply to this thread.