How to Draw Text Somewhere on the map

Here is screenshot:
http://img1.uploadscreenshot.com/images/orig/2/4022013368-orig.jpg

So, how to do this? Can you help with example script please?

It uses something called 3D2D.

I suggest learning lots of basic lua first mate but here’s the link.

Can you post an example?
This just dont work :frowning:

cam.Start3D2D( Vector(0, 0, 0), Angle(0, 0, 0), 1 )
draw.DrawText(“Your Mother”, “ScoreboardText”, 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
cam.End3D2D()

it does work mate, it prints it at position 0,0,0 … try 500,500,500 on GM_Construct

also post me your code.



function DrawBox()
cam.Start3D2D( Vector(500, 500, 500), Angle(0, 0, 0), 1 )
draw.DrawText("Your Mother", "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
cam.End3D2D() 
end

hook.Add("HUDPaint", "DrawBox", DrawBox);


Whats the HUDPaint for lol… it isn’t bound to your HUD. Delete that hook.

and just give it a concommand that runs the function that u can do in gmod.


TS.AdminConsoleCommand( "rpa_draw_this_shit", false, function( ply, cmd, arg )
cam.Start3D2D( Vector(500, 500, 500), Angle(0, 0, 0), 1 )
draw.DrawText("Your Mother", "ScoreboardText", 0, 0, Color(255, 255, 255, 255), TEXT_ALIGN_CENTER )
cam.End3D2D() 
end
 

is ok?
or can you post example please. working example.

TS.AdminConsoleCommand( “rpa_draw_this_shit”, false, function( ply, cmd, arg ) wat?

and ok hang on

Mess with my scoreboard i found blah

[lua]
ENT.Type = “anim”
ENT.Base = “base_anim”
ENT.Author= “Flawless”
ENT.Category = “”
ENT.PrintName = “3D2D ScoreBoard”

ENT.Spawnable= true
ENT.AdminSpawnable= true
[/lua]

[lua]
AddCSLuaFile( “shared.lua” )
AddCSLuaFile( “cl_init.lua” )

include(‘shared.lua’)

function ENT:SpawnFunction( ply, tr )
local SpawnPos = tr.HitPos + tr.HitNormal * 16
ply:SetViewEntity( self )
local ent = ents.Create( “sent_3d2dscore” )
ent:SetPos( SpawnPos )
ent:Spawn()
ent:Activate()
ent:SetColor(255, 255, 255, 255)
return ent
end

function ENT:Use( activator, caller )

end

function ENT:Initialize()
self.Entity:PhysicsInit( SOLID_VPHYSICS )
self.Entity:SetMoveType( MOVETYPE_NONE )
self.Entity:SetSolid( SOLID_VPHYSICS )
local phys = self:GetPhysicsObject()

    if (phys:IsValid()) then
            phys:EnableGravity(true)
            phys:SetMass(30)
            phys:Wake()
    end
    self.Entity:SetColor(255, 255, 255, 255)
    self:SetNotSolid(true)

end

function ENT:Think()
self.BaseClass.Think(self)
self.Entity:NextThink(CurTime()+0.04)
return true
end

function ENT:OnTakeDamage( dmginfo )
self.Entity:TakePhysicsDamage( dmginfo )
end

function ENT:Touch( ent )

end
[/lua]

[lua]
include( “shared.lua” )

function ENT:Initialize()

end

function ENT:Draw()
self.Entity:SetRenderBounds( Vector(-1000,-1000,-1000), Vector(1000,1000,1000) )

    local pos = self.Entity:GetPos() + self.Entity:GetUp() * 50
    local ang = self.Entity:GetAngles() + Angle(0,0,90)
   
    cam.Start3D2D(pos, ang, 1)  
            surface.SetDrawColor(Color(195,195,195,255))
            surface.DrawRect(-100, 0, 200, 80)
           
            surface.SetDrawColor(Color(0,162,232,255))
            surface.DrawRect(-100, 0, 200, 12)
           
            surface.SetDrawColor(Color(0,0,0,255))
            surface.DrawRect(-82, 15, 50, 60)
            surface.DrawRect(-28, 15, 50, 60)
            surface.DrawRect(26, 15, 50, 60)
    cam.End3D2D()
   
    --[[cam.Start3D2D(pos, ang, 1)  
            surface.SetDrawColor(Color(0,162,232,255))
            surface.DrawRect(-100, -200, 200, 12)
    cam.End3D2D()]]
   
    cam.Start3D2D(pos, ang, 0.4)  
            draw.SimpleText("Xuras Player List", "ScoreboardHead", 0, 2, Color(255,255,255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
           
            surface.SetDrawColor(Color(0,162,232,255))
           
            surface.DrawRect(-203.25, 38, 120, 10)
            surface.DrawRect(-203.25 + 135, 38, 120, 10)
            surface.DrawRect(-203.25 + 135 * 2, 38, 120, 10)
           
            draw.SimpleText("Players", "UIBold", -200, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
            draw.SimpleText("Ping", "UIBold", -120, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
           
            draw.SimpleText("Players", "UIBold", -200 + 135, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
            draw.SimpleText("Ping", "UIBold", -120 + 135, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
           
            draw.SimpleText("Players", "UIBold", -200 + 135 * 2, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
            draw.SimpleText("Ping", "UIBold", -120 + 135 * 2, 42, Color(255,255,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
    cam.End3D2D()
   
    --[[cam.Start3D2D(pos, ang, 0.4)  
            draw.SimpleText("Server", "UIBold", -196, 6, Color(0,124,191,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
    cam.End3D2D()]]
   
    local PlayerPos = 60
    local i = 1
    local add = 0
    for k, v in pairs(player.GetAll())do
            if(v:IsPlayer())then
                    cam.Start3D2D(pos, ang, 0.4)
                            local name = v:Name()
                            local ping = v:Ping()
                           
                            if(tonumber(string.len(name)) >= 12)then
                                    name = string.sub(name, 1, 11) .. ".."
                            end
                            if(i == 13 ||i == 25) then PlayerPos = 60 end
                            if(i >= 13) then add = 135 end
                            if(i >= 25) then add = 135 * 2 end
                           
                            local color = Color(128, 128, 128, 255)
                           
                            if (v:Alive()) then color = Color(255,255,255) end
                           
                            if (v:IsAdmin()) then color = Color(0,255,0,255) end
                            if (v:IsAdmin() and not v:Alive()) then color = Color(128,200,128,255) end
                                                          
                            draw.SimpleText(name, "UIBold", -200 + add, PlayerPos, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
                            draw.SimpleText(ping, "UIBold", -120 + add, PlayerPos, color, TEXT_ALIGN_LEFT, TEXT_ALIGN_CENTER)
                    cam.End3D2D()
                    PlayerPos = PlayerPos + 11
                    i = i + 1
            end
    end
   
    return true

end

function ENT:Think()
return true
end

function ENT:OnRemove()

end

function ENT:DrawEntityOutline( size )

end
[/lua]

Shared - init - cl_init … yeh its got to be an ENT as the angles and pos doesnt work on HUDPaint.

Can you make SIMPLE example ? :X
but ok i try this

[editline]09:19AM[/editline]

Hm… but how to draw just text on the map? :frowning: I need this autodraw somwhere when server start…

There is no simpler way to do this. Just create a sent for the text and spawn on server start :smiley:

How to spawn and freeze ent when server start?

[editline]10:51AM[/editline]

I know how to spawn, but how to spawn freezed object?

You don’t need to do 3D2D in an ENTs draw, you can do it in a PostDrawOpaqueRenderables hook, but the problem with this is that it has no z index and may draw under or over everything else on the map.

I know server with 25+ text labels on walls, he make 25+ entities?

What is wrong with drawing 25+ text labels on a single entity? Except of course for the fact you shouldn’t use an entity for that.

How to do that? How to make 1 entity can display any text?
Can you post simple example please.

[editline]11:49AM[/editline]

can you help me with that?

Basically make a table you canset for each map that plots the positions of the text due to the current map

But how to make custom text? I dont want create XX entitys, how to use 1 entity to create more then 2 text labels on the map?

cam.Start3D2D
code blah
cam.End3D2D

cam.Start3D2D
code blah
cam.End3D2D

cam.Start3D2D
code blah
cam.End3D2D

As many times as you want really…

No i mean not this > http://img1.uploadscreenshot.com/images/orig/2/4116070752-orig.jpg
I mean something like this >
When server starts he spawn for example entity MYTEXT and 2177.94, -2478.44, 807.03 position with parameters “Blah” and another MYTEXT entity with parameters “Blah2” and 2732.78, 30.75, 1120.03.
And you get Text Blah at 2177.94, -2478.44, 807.03 and Blah2 at 2732.78, 30.75, 1120.03.
Sorry for my english, but can you post example of it ^^^^^^^^^^^ if it can be possible.

Its what i just said u douche.

Read what i previously said… All of that and as many as you want in one file.