Proper text in derma?

What is the best way to do text in derma?
Example i wanna make text near a button.

nvm .

Yeah you can use SetPos on a DLabel.

This isn’t working, nothing appears on my sheet
[lua]namelabel = vgui.Create(“DLabel”, SheetItemOne)
namelabel:SetText(“Character Name”)
namelabel:SetPos( 5, 5 )
namelabel:SetSize( 155, 5 )[/lua]

Eh. I’ve never been a fan of DLabels. They’re too restrictive.

In my opinion, if you want to do text you should use the draw library, as so:

[lua]
local paint_panel = vgui.Create(“DPanel”,parent)
paint_panel:SetPos(0,0)
paint_panel:SetSize(parent:GetWide(),parent:GetTall())
paint_panel.Paint = function()
draw.DrawText( “Hello World!”, “ScoreboardText”, parent:GetWide() / 2, 3, Color(255,0,0), 1)
end[/lua]

It’s hardly any longer and much more versatile.

Also I’m trying to find out how can i change the player’s name.
Will this work?
[lua]local nameentry = vgui.Create( “DTextEntry”, SheetItemOne )
nameentry:SetPos( 20, 40 )
nameentry:SetTall( 20 )
nameentry:SetWide( 120 )
nameentry:SetEnterAllowed( true )
nameentry.OnEnter = function()
ply:SetName(myText:GetValue())
end[/lua]

You can’t change the players name.

You would have to store a string for each player of their characters name then hide the default name showing when you look at someone (HUDDrawTargetID) and draw your own in HUDPaint showing their character name instead of their steam name.

you would use usermessage strings and setinfo name in a think hook.

I was going to suggest RunConsoleCommand but apparently name is blocked.

I will try making what Emz said

no need

this way is pretty simple, just with a concommand. it’s also ** UNTESTED**

[lua]
if ( SERVER ) then

concommand.Add(“setname” , function(ply , cmd, args)
if !ply:IsAdmin() then
ply:ChatPrint(“You do not have permission to do this.”)
elseif not args[2] then
Ply:ChatPrint(“Please specify a player and a name to set.”)
else
for k , t in ipairs(player.GetAll()) do
if string.find(string.lower(t:Nick()) , string.lower(args[1])) then
umsg.Start(“newname”, t)
umsg.String( args[2] )
umsg.End()

		end
	end 
end

end )

end

if ( CLIENT ) then

function newname( um )
hook.Add(“Think”, “newnamethink”, function()
RunConsoleCommand(“setinfo”, “name”, um:ReadString())
end )
end
usermessage.Hook(“newname”, newname)

end[/lua]