Sometimes I get this error, and sometimes I don't. The error is:
[code]
Hook 'DrawTime' Failed: lua\includes\modules\draw.lua:75: bad argument #1 to 'GetTextSize' (string expected, got nil)
[/code]
Here is my code for the part of the HUD it's affecting:
[lua]local function TimerStatus()
timetowrite = "Round Finished"
end
usermessage.Hook("TimerStatus", TimerStatus)
function ReceiveTime( um )
roundtime = um:ReadShort()
timetowrite = "Time: " .. string.ToMinutesSeconds(tostring(roundtime))
end
usermessage.Hook("SendTime", ReceiveTime)
function DrawTime()
draw.SimpleText(timetowrite, "Bullet_HUD", ScrW() / 2, 20, Color(255, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
hook.Add("HUDPaint", "DrawTime", DrawTime)[/lua]
Anyone know why this is happening?
[lua]
local timetowrite = "Loading..."
local function TimerStatus()
timetowrite = "Round Finished"
end
usermessage.Hook("TimerStatus", TimerStatus)
function ReceiveTime( um )
roundtime = um:ReadShort()
timetowrite = "Time: " .. string.ToMinutesSeconds(tostring(roundtime))
end
usermessage.Hook("SendTime", ReceiveTime)
function DrawTime()
draw.SimpleText(timetowrite, "Bullet_HUD", ScrW() / 2, 20, Color(255, 0, 0, 255), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
end
hook.Add("HUDPaint", "DrawTime", DrawTime)
[/lua]
Before you receive one of those usermessages, timetowrite doesn't exist. Try giving it a blank initial value by putting
timetowrite = ""
outside any function.
Oh, Ok. Thanks both of you.
Erm, it is not your code...
[QUOTE=Loures;24643689]Erm, it is not your code...[/QUOTE]
Ya, sorry. You get the credit...
Sorry, you need to Log In to post a reply to this thread.