Need help with timer

Hello

I want it so that the “draw.DrawText” appears AFTER 2 seconds, but how?
Here is my full code:


/*if ( CLIENT ) then
	surface.CreateFont( "wastedfont", {
		font = "pricedown bl",
		size = 20,
		weight = 400,
		antialias = true
} )
*/
if ( CLIENT ) then
	surface.CreateFont( "wastedfont", {
		font = "pricedown bl",
		size = 50,
		weight = 400,
		blursize = 0,
		antialias = true,
		outline = true,
		shadow = false,
		strikeout = false,
		scanlines = 0
	} )

	function wastedmessageHUD()
	if not LocalPlayer():Alive() then
				draw.DrawText("wasted", "wastedfont", ScrW() * 0.5, ScrH() * 0.50, Color(220, 0, 0, 255),TEXT_ALIGN_CENTER)
		end
	end
	hook.Add("HUDPaint", "WastedMessageHud", wastedmessageHUD)
end

if ( CLIENT ) then
	function DrawBinoc()
		if not LocalPlayer():Alive() then
				local tab = {}
					tab[ "$pp_colour_addr" ] = 0
					tab[ "$pp_colour_addg" ] = 0
					tab[ "$pp_colour_addb" ] = 0
					tab[ "$pp_colour_brightness" ] = -0.25
					tab[ "$pp_colour_contrast" ] = 1.39
					tab[ "$pp_colour_colour" ] = 0
					tab[ "$pp_colour_mulr" ] = 0
					tab[ "$pp_colour_mulg" ] = 0
					tab[ "$pp_colour_mulb" ] = 0 
 
				DrawColorModify( tab ) 
		end
	end
end
 
hook.Add( "RenderScreenspaceEffects", "BinocDraw", DrawBinoc )

/*function wastedmessage( ply )
if !ply:Alive() then
          draw.DrawText("Wasted!", "wastedfont", ScrW() / 2 - 70, ScrH() - 63, Color(255, 0, 0, 255),TEXT_ALIGN_CENTER)
		end
	end

end
*/
 
if ( SERVER ) then
function slowmodeath()
 
		game.SetTimeScale(0.3)
 
end

 
function removeslowmo()
 
	game.SetTimeScale(1.0)
 
end

local noise = Sound("deathsound.wav")
hook.Add("PlayerDeathSound", "DeFlatline", function() return true end)
hook.Add("PlayerDeath", "NewSound", function(vic,unused1,unused2) vic:EmitSound(noise) end)
hook.Add("PlayerDeath", "TimeScaleDeath", slowmodeath)
hook.Add("PlayerSpawn", "RemoveSlowmo", removeslowmo)
//hook.Add("PlayerDeath", "Message", wastedmessageHUD)
 
end

//2.2 <- ignore this :D

Replace

[lua]draw.DrawText(“wasted”, “wastedfont”, ScrW() * 0.5, ScrH() * 0.50, Color(220, 0, 0, 255),TEXT_ALIGN_CENTER)[/lua]

with

[lua]timer.Simple(2, function() draw.DrawText(“wasted”, “wastedfont”, ScrW() * 0.5, ScrH() * 0.50, Color(220, 0, 0, 255),TEXT_ALIGN_CENTER) end)[/lua]

Think that should do the trick.

Now the text doesn’t appear :frowning:

Why did you post this thread again and snip your old one?

what bout this?

[lua]function wastedmessageHUD()
if not LocalPlayer():Alive() then
timer.Simple(2, function() draw.DrawText(“wasted”, “wastedfont”, ScrW() * 0.5, ScrH() * 0.50, Color(220, 0, 0, 255),TEXT_ALIGN_CENTER)
end)
end[/lua]

Nope, nothing happens. :frowning:

[editline]16th February 2014[/editline]

Because this one works, now i have got an OTHER problem!
This isn’t the same problem like yesterday :smiley:

Try to replace your whole file with this (make sure to do backup if you need)

[lua]
*if ( CLIENT ) then
surface.CreateFont( “wastedfont”, {
font = “pricedown bl”,
size = 20,
weight = 400,
antialias = true
} )
*/
if ( CLIENT ) then
surface.CreateFont( “wastedfont”, {
font = “pricedown bl”,
size = 50,
weight = 400,
blursize = 0,
antialias = true,
outline = true,
shadow = false,
strikeout = false,
scanlines = 0
} )

function printmessageHUD()
draw.DrawText("wasted", "wastedfont", ScrW() * 0.5, ScrH() * 0.50, Color(220, 0, 0, 255),TEXT_ALIGN_CENTER)

end

function wastedmessageHUD()
if not LocalPlayer():Alive() then
			timer.Simple( 5, function() printmessageHUD()
	end)
end
hook.Add("HUDPaint", "WastedMessageHud","printmessageHUD", wastedmessageHUD)

end

if ( CLIENT ) then
function DrawBinoc()
if not LocalPlayer():Alive() then
local tab = {}
tab[ “$pp_colour_addr” ] = 0
tab[ “$pp_colour_addg” ] = 0
tab[ “$pp_colour_addb” ] = 0
tab[ “$pp_colour_brightness” ] = -0.25
tab[ “$pp_colour_contrast” ] = 1.39
tab[ “$pp_colour_colour” ] = 0
tab[ “$pp_colour_mulr” ] = 0
tab[ “$pp_colour_mulg” ] = 0
tab[ “$pp_colour_mulb” ] = 0

			DrawColorModify( tab ) 
	end
end

end

hook.Add( “RenderScreenspaceEffects”, “BinocDraw”, DrawBinoc )

/*function wastedmessage( ply )
if !ply:Alive() then
draw.DrawText(“Wasted!”, “wastedfont”, ScrW() / 2 - 70, ScrH() - 63, Color(255, 0, 0, 255),TEXT_ALIGN_CENTER)
end
end

end
*/

if ( SERVER ) then
function slowmodeath()

	game.SetTimeScale(0.3)

end

function removeslowmo()

game.SetTimeScale(1.0)

end

local noise = Sound(“deathsound.wav”)
hook.Add(“PlayerDeathSound”, “DeFlatline”, function() return true end)
hook.Add(“PlayerDeath”, “NewSound”, function(vic,unused1,unused2) vic:EmitSound(noise) end)
hook.Add(“PlayerDeath”, “TimeScaleDeath”, slowmodeath)
hook.Add(“PlayerSpawn”, “RemoveSlowmo”, removeslowmo)
//hook.Add(“PlayerDeath”, “Message”, wastedmessageHUD)

end

//2.2 <- ignore this :D[/lua]

[editline]16th February 2014[/editline]

edited

Still not working.

Any errors?

Nope