Derma Help!

[lua]


---- Made By Greyfox -----


–clientside lua is BELOW THIS GOES IN lua/autorun/client folder
– you need to copy this code and then name the file cl_deathmessages.lua
function DrawDeathMessage()

– give me credit!
local DeathMessages = {
“You have died, you forget everything that happened in the past. You may not return to that area for 2 minutes!”,
}

local LDFrame = vgui.Create( “DFrame” )
LDFrame:SetPos( ScrW() / 2 - 250,ScrH() / 2 )
LDFrame:SetSize( 525, 128 )
LDFrame:SetTitle( “New Life Rule - NLR” )
LDFrame:SetVisible( true )
LDFrame:SetDraggable( true )
LDFrame:ShowCloseButton( false )
LDFrame:SetBackgroundBlur( true )
LDFrame:MakePopup()

local PaintPanel = vgui.Create( “DPanel”, LDFrame )

PaintPanel:SetPos( 5, 25 )
PaintPanel:SetSize( 495, 90 )
PaintPanel.Paint = function()
surface.SetDrawColor( 50, 50, 50, 255 )
surface.DrawRect( 0, 0, PaintPanel:GetWide(), PaintPanel:GetTall() )
–PaintPanel:SetCursor(“hand”);
end

local Dlabel = vgui.Create(“DLabel”, PaintPanel);
Dlabel:SetText(DeathMessages[math.random(1,#DeathMessages)]);
Dlabel:SetSize(490, 30);
Dlabel:SetPos(10, 20);

local OKButton = vgui.Create(“DButton”, PaintPanel);
OKButton:SetText(“Start a new life?”);
OKButton:SetSize(100, 30);
OKButton:SetPos(10, 50);
OKButton.DoClick = function()
LDFrame:Close()
RunConsoleCommand(“dmspawn”)
end
end
concommand.Add(“DrawDeathMsg”, DrawDeathMessage)
[/lua]

Im having a problem. It wont show the full sentence. It shows this

Its supose to say!

But it only shows up to the fo.

I’m not sure it will help, but try using [[ and ]] around the message, instead of quotes.

Didn’t work can anyone else help?

The length of your sentence is greater than the width of your DLabel. DLabels do not have built in word wrap.

In this instance, the width of the sentence, “You have died, you forget everything that happened in the past. You may not return to that area for 2 minutes!” is greater than 490, the width of the DLabel.

So which size should I make it?

Play around with it, just some guess and check.

If you really gotta know exact values, you can find the width and height of a string with a given font using **[Surface.GetTextSize

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Surface.GetTextSize)**

495?

Just keep going up by 5 until it doesn’t get cut off.

Dont think the “,” is supposed to there.

[editline]07:06PM[/editline]

nvm, didnt read thread.

DLabel:SizeToContents()

Put it anywhere after you set the text.