• Temporary text with auto changing
    3 replies, posted
Hi, i was wondering how to make temporary text on screen that will change text after some time? I want to make some text appearing at screen that will be displayed every 50 second but with random text. I was thinking to make random table to make it work but i don't know hot to exactly make entire script to work. I used this to display text on screen [CODE]hook.Add( "HUDPaint", "drawtext", function() surface.SetFont( "MyFont" ) surface.SetTextColor( 255, 255, 255, 255 ) surface.SetTextPos( 1500, 75 ) surface.DrawText( "hint" ) end )[/CODE]
[QUOTE=Ia_grib;52906058]You can just use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/draw/DrawText]draw.DrawText[/url]: [lua]local hints = { -- table of options "Random text 1", "Random text 2" } local current = math.random(#hints) -- index of currently displayed text from the table local function newRandom() -- function to change current text to some other random entry local old = current -- prevent same items from being chosen twice in a row while current == old do current = math.random(#hints) end end timer.Create("My Hints", 50, 0, newRandom) local function drawText() -- function to actually draw our text draw.DrawText(hints[current]) end hook.Add("HUDPaint", "My Hints", drawText)[/lua]This is a very basic example, but it should give you the general idea of how it's done.[/QUOTE] Thanks,you really helped me. But is it possible to make text displaying on screen for 10 seconds and after it will disappear and then after some time will appear new text?
Yes, this should help you. [url]https://www.lua.org/pil/4.2.html[/url] [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Global/CurTime]CurTime[/url]
Sorry, you need to Log In to post a reply to this thread.