• 1. Making text colored. 2. Time befor you can respawn.
    7 replies, posted
Alright so i need help with to things here. 1. How would a make this text a special color? [code] pl:PrintMessage( HUD_PRINTCENTER, "Here goes some random text in a nice color!" ) [/code] 2. I want the players to have a "cool down" when they die. So when the player dies text comes up with a timer going from 60 seconds to 0 and then they will respawn. How would i do those? Thank you in advanced.
1. ???? 2. Something like this... [lua] local I = 60 timer.Create("Countdown",1,function() if( I>0 ) then I= I-1 timer.Start("Countdown") else return end) if (!ply:Alive()) then timer.Start("Countdown") end [/lua]
[QUOTE=devinpro;25766742]1. ???? 2. Something like this... [lua] local I = 60 timer.Create("Countdown",1,function() if( I>0 ) then I= I-1 timer.Start("Countdown") else return end) if (!ply:Alive()) then timer.Start("Countdown") end [/lua][/QUOTE] 1. I want to make my text which is printed on the screen black and not white. How would i do that? 2. Would it just work like that? Or would i have to add a hook for it? Like the PlayerDeath hook?
[QUOTE=Crap-Head;25767608]1. I want to make my text which is printed on the screen black and not white. How would i do that? 2. Would it just work like that? Or would i have to add a hook for it? Like the PlayerDeath hook?[/QUOTE] No it wouldn't work just like that, as the countdown isn't getting printed to anywhere, its just counting down, you only need to add hooks when your using a function and don't want to override an existing a hook.
snip
You would be using a HUDPaint hook, so let me string up some nice functions brb [editline]2nd November 2010[/editline] This should sort question 1, all you need to add is all the other enumerations after, i only added HUD_PRINTCENTER [LUA] local old = PrintMessage function PrintMessage( enum, text, color ) if !color then local r = old( enum, text ) return false end if enum = HUD_PRINTCENTER then if CLIENT then hook.Add( "HUDPaint", "PRINTMESSAGE:" .. text , function() draw.SimpleText(text, "ScoreboardText", ScrW() / 2 , ScrH() / 2 - 70, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function YourFunction( t ) hook.Remove( "HUDPaint", "PRINTMESSAGE:" .. t ) end timer.Simple( 5, YourFunction ) return true else for K,V in pairs( player.GetAll() ) do V:SendLua( [[PrintMessage( ]] .. enum .. [[ , "]] .. text .. [[" , Color( tonumber(]] .. color.r .. [[) , tonumber(]] .. color.g .. [[) , tonumber(]] .. color.b .. [[) , tonumber(]] .. color.a .. [[)))]]); end return true end end end _R.Player.old = _R.Player.PrintMessage function _R.Player.PrintMessage( enum, text, color ) if !color then self:old( enum, text ) return false end if enum = HUD_PRINTCENTER then self:SendLua( [[PrintMessage( ]] .. enum .. [[ , "]] .. text .. [[" , Color( tonumber(]] .. color.r .. [[) , tonumber(]] .. color.g .. [[) , tonumber(]] .. color.b .. [[) , tonumber(]] .. color.a .. [[)))]]); end end _R.Player.old = nil old = nil [/LUA]
[QUOTE=Ningaglio;25810116]You would be using a HUDPaint hook, so let me string up some nice functions brb [editline]2nd November 2010[/editline] This should sort question 1, all you need to add is all the other enumerations after, i only added HUD_PRINTCENTER [LUA] local old = PrintMessage function PrintMessage( enum, text, color ) if !color then local r = old( enum, text ) return false end if enum = HUD_PRINTCENTER then if CLIENT then hook.Add( "HUDPaint", "PRINTMESSAGE:" .. text , function() draw.SimpleText(text, "ScoreboardText", ScrW() / 2 , ScrH() / 2 - 70, color, TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER) end local function YourFunction( t ) hook.Remove( "HUDPaint", "PRINTMESSAGE:" .. t ) end timer.Simple( 5, YourFunction, t ) return true else for K,V in pairs( player.GetAll() ) do V:SendLua( [[PrintMessage( ]] .. enum .. [[ , "]] .. text .. [[" , Color( tonumber(]] .. color.r .. [[) , tonumber(]] .. color.g .. [[) , tonumber(]] .. color.b .. [[) , tonumber(]] .. color.a .. [[)))]]); end return true end end end _R.Player.old = _R.Player.PrintMessage function _R.Player.PrintMessage( enum, text, color ) if !color then self:old( enum, text ) return false end if enum = HUD_PRINTCENTER then self:SendLua( [[PrintMessage( ]] .. enum .. [[ , "]] .. text .. [[" , Color( tonumber(]] .. color.r .. [[) , tonumber(]] .. color.g .. [[) , tonumber(]] .. color.b .. [[) , tonumber(]] .. color.a .. [[)))]]); end end _R.Player.old = nil old = nil [/LUA][/QUOTE] You forgot to supply t into the simple timer when using YourFunction, fixed it in the quote
Well, to make it easier. You can use chat.AddText to add colored text to a textbox [lua] ply:SendLua( "chat.AddText(" Color(255,255,255), [[ Some text here ]], Color(another,color,here), [[ Some more text, and so on. ]] " ) [/lua] But of course it's different if you want it like to show up in the middle of the screen.
Sorry, you need to Log In to post a reply to this thread.