Jump to content

Bad Argument @guiSetFont


FuriouZ

Recommended Posts

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 :)

Link to comment

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

Link to comment

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")   

Link to comment
Yeah lol ... but ...

mta-screen_2013-08-14_16-23-23.png

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 

Link to comment

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 
  

Link to comment
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.

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...