FuriouZ Posted August 14, 2013 Posted August 14, 2013 Hello! I have problem with guiSetFont ...debugscript says warnings WARNING: Shodown\c_arena.lua:40: Bad argument @ 'guiSetFont' [Expected gui-font at argument 2,got nil] Fonts (line 19-21) --'fonts' local SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) local ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) Problem (line 38-42) --SELECT WORLD LABEL GUIEditor.label[1] = guiCreateLabel(0.27, 0.02, 0.47, 0.12, "Select World", true, GUIEditor.staticimage[1]) guiSetFont(GUIEditor.label[1], SignPainter45) --line 40 guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") Thanks for helping
tosfera Posted August 14, 2013 Posted August 14, 2013 The fonts you created are displayed as Local, are they in the same function or another function? If it are 2 different functions, remove the local infront of the font names.
FuriouZ Posted August 14, 2013 Author Posted August 14, 2013 No,i don't want give whole code,but i give start where are these fonts --'fonts' local SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) local ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) GUIEditor = { button = {}, staticimage = {}, label = {} } ------------- --World Gui-- ------------- addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.staticimage[1] = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "img/backround.png", true) showCursor(true) --SELECT WORLD LABEL GUIEditor.label[1] = guiCreateLabel(0.27, 0.02, 0.47, 0.12, "Select World", true, GUIEditor.staticimage[1]) guiSetFont(GUIEditor.label[1], SignPainter45) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") --TOTAL PLAYERS LABEL GUIEditor.label[2] = guiCreateLabel(0.38, 0.89, 0.24, 0.06, "Total players:", true, GUIEditor.staticimage[1]) guiSetFont(GUIEditor.label[2], ForzaLight15) guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "center") I hope,it is enough
tosfera Posted August 14, 2013 Posted August 14, 2013 Like I said, remove the local's. that will fix 1 part. Cause it has to work without the local's, if that doesn't work try this; GUIEditor = { button = {}, staticimage = {}, label = {} } ------------- --World Gui-- ------------- addEventHandler("onClientResourceStart", resourceRoot, function() GUIEditor.staticimage[1] = guiCreateStaticImage(0.00, 0.00, 1.00, 1.00, "img/backround.png", true) showCursor(true) -- labels SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) --SELECT WORLD LABEL GUIEditor.label[1] = guiCreateLabel(0.27, 0.02, 0.47, 0.12, "Select World", true, GUIEditor.staticimage[1]) guiSetFont(GUIEditor.label[1], SignPainter45) guiLabelSetHorizontalAlign(GUIEditor.label[1], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[1], "center") --TOTAL PLAYERS LABEL GUIEditor.label[2] = guiCreateLabel(0.38, 0.89, 0.24, 0.06, "Total players:", true, GUIEditor.staticimage[1]) guiSetFont(GUIEditor.label[2], ForzaLight15) guiLabelSetHorizontalAlign(GUIEditor.label[2], "center", false) guiLabelSetVerticalAlign(GUIEditor.label[2], "center")
FuriouZ Posted August 14, 2013 Author Posted August 14, 2013 Nothing changed,still same problem If i restart script,then there isn't any problem,but if i restart again,then again fonts doesn't appear
tosfera Posted August 14, 2013 Posted August 14, 2013 I see what you mean, I got the function from the wiki and when I use it, it also gives me an error. Not sure what it is though... I'll play around with it for a few mins.
tosfera Posted August 14, 2013 Posted August 14, 2013 Yeah lol ... but ... I got it working like this; addEventHandler("onClientResourceStart", root, function () myLabel = guiCreateLabel( 100, 300, 400, 50, "GUI label", false ) myFont = guiCreateFont( "font.ttf", 20 ) -- Create GUI custom font if not ( myFont ) then myFont = guiCreateFont( "font.ttf", 20 ) -- Create GUI custom font end if not ( guiGetFont(myLabel) == myFont ) then setTimer(function () guiSetFont( myLabel, myFont ); end, 50, 1); end end ); I got another working way; addEventHandler("onClientResourceStart", root, function () myFont = guiCreateFont( "font.ttf", 20 ) -- Create GUI custom font myLabel = guiCreateLabel( 100, 300, 400, 50, "GUI label", false ) if not ( myFont ) then myFont = guiCreateFont( "font.ttf", 20 ) -- Create GUI custom font end addEventHandler("onClientPreRender", getRootElement(), setFont) end ); function setFont ( ) guiSetFont( myLabel, myFont ); end
FuriouZ Posted August 14, 2013 Author Posted August 14, 2013 Oh,i got it ! Thank you ! This is my working way addEventHandler("onClientResourceStart", root, function () SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) if not ( SignPainter45 or ForzaLight15) then SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) end addEventHandler("onClientPreRender", getRootElement(), setFont) end ); function setFont ( ) guiSetFont( GUIEditor.label[1], SignPainter45 ); guiSetFont( GUIEditor.label[2], ForzaLight15 ); end
tosfera Posted August 14, 2013 Posted August 14, 2013 Oh,i got it ! Thank you ! This is my working way addEventHandler("onClientResourceStart", root, function () SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) if not ( SignPainter45 or ForzaLight15) then SignPainter45 = guiCreateFont("fonts/SignPainter.ttf", 45) ForzaLight15 = guiCreateFont("fonts/ForzaLight.ttf", 15) end addEventHandler("onClientPreRender", getRootElement(), setFont) end ); function setFont ( ) guiSetFont( GUIEditor.label[1], SignPainter45 ); guiSetFont( GUIEditor.label[2], ForzaLight15 ); end Haha you can't do everything yourself, a little support is always welcome! No problem mate.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now