• How do I create text to display on screen, with Derma, without a background?
    7 replies, posted
The title almost fills in all the info. I want to make an adverter, much like Assmod's, but I already have a HUD box created. So I just need text to appear, how would I approach this? Thanks, -Jay
[QUOTE=Jaastin;31461865]The title almost fills in all the info. I want to make an adverter, much like Assmod's, but I already have a HUD box created. So I just need text to appear, how would I approach this? Thanks, -Jay[/QUOTE] I believe this is what you're looking for: [b][url=http://wiki.garrysmod.com/?title=Surface.DrawText]Surface.DrawText [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
You should probably use one of the various text drawing functions. Its not derma but its better suited for this imo.
So, I should go along with Derma?
Like Said it would probably be better to use one of the text drawing functions, here are a few: [b][url=http://wiki.garrysmod.com/?title=Surface.DrawText]Surface.DrawText [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [b][url=http://wiki.garrysmod.com/?title=Draw.Text]Draw.Text [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] [b][url=http://wiki.garrysmod.com/?title=Draw.SimpleText]Draw.SimpleText [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]
[lua] local adverts = {"Advert #1", "Advert #2", "Advert #3", "Advert #4", "Advert #5", "Advert #6"}; /*fill this table with your advertisements*/ local cura = adverts[math.random(1, #adverts)]; /*Generate first advertisement to display*/ local currentt = CurTime() /*Grab the current time*/ /*function used to generate a new advertisement from the table, when called*/ function GenerateNewAdvertisement() local newa = adverts[math.random(1, #adverts)] return tostring(newa); end /*Every 180 seconds, call the function to generate a new advertisements*/ hook.Add("Tick", "UpdateAdvertisement", function() if( CurTime() - currentt > 180 ) then cura = GenerateNewAdvertisement(); currentt = CurTime() else return; end end) /*Draw our roudned boxes, and the text*/ hook.Add("HUDPaint", "Advertise_Adverts_Table", function() if( !cura || cura == nil ) then return; end local w, h = surface.GetTextSize( cura ); draw.RoundedBox(6, ScrW() - 215, ScrH() - (ScrH() - 15), w + 31, h + 10, Color(255, 255, 255)); draw.RoundedBox(6, ScrW() - 212, ScrH() - (ScrH() - 17), w + 25, h + 6, Color(0, 0, 0)); draw.SimpleTextOutlined(tostring(cura), "TargetID", ScrW() - 200, ScrH() - (ScrH() - 19), Color(255, 255 ,255), TEXT_ALIGN_LEFT, TEXT_ALIGN_LEFT, 0.5, Color(0, 255, 0)); end) [/lua] Small little advertiser, somewhat ugly, I'm sure you can get someone help you to redesign it.
Tinu-c, thanks alot! I'll review the code and try to learn. I just believe this is too advanced for me at the moment, and thanks to all the help! :) Getting: [addons\headbob\lua\autorun\advert.lua:7] unexpected symbol near '�' Edit: Fixed, thanks, it wurksss :D
No problem, the code is pretty ugly, could be fixed but if it works.
Sorry, you need to Log In to post a reply to this thread.