Jump to content

Help With Freeroam Panel


Zuher Laith

Recommended Posts

Hi ..

Recently I Decided to Add Feature's to Freeroam Panel ..

Like Getting Player Name, Ping, Money, etc.

Here is a Part of my Edit's:

Please Don't Give Attention to Arabic Letters.

--------------------------- 
-- Hnons window 
--------------------------- 
  
wndHnons = { 
    'wnd', 
    text = 'معلومات الاعب        ', 
    x = 5, 
    y = 10, 
    width = 200, 
    controls = { 
        {'lbl', text='your name :' .. getPlayerName(g_Me) .. ' '}, 
        {'lbl', text='your ping :' .. getPlayerPing(g_Me) .. ' '}, 
        {'lbl', text='your skin :' .. getPedSkin(g_Me) .. ' '}, 
        {'lbl', text='your Money :' .. getPlayerMoney(g_Me) .. ' '}, 
        {'lbl', text='your Armor :' .. getPedArmor(g_Me) .. ' '}, 
        {'btn', id='إغلاق  ', closeswindow=true} 
    }, 
  
} 
  

So this Code Give's The Value's Only On Panel Resource Start ..

I Want to make it work by Timer or something ..

here's what i tried:

setTimer(getPedArmor(g_Me),2000,0) 

am I working with the Wrong Code or something else?

Please help ..

Link to comment

You should create a timer that changes these fields. So, let's say that you got a label called; txtPlayerName, you should update that each second in your timer;

setTimer ( function() 
        guiSetText ( "txtPlayerName", getPlayerName ( localPlayer ) ); 
        guiSetText ( "txtPlayerPing", getPlayerPing ( localPlayer ) ); 
    end, 1000, 0 
); 

Link to comment

@tosfera

I guess the Freeroam looks pretty different of Designing Side ..

wndMain = { 
    'wnd', 
       text = 'Player Panel', 
    x = 10, 
    y = 150, 
    width = 277, 
    controls = { 
                {'lbl', id='namelbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
        {'lbl', id='pinglbl', text = 'Your Ping: ' .. getPlayerPing(g_Me) .. ' '}, 
        {'br'}, 
        {'lbl', id='moneylbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
        -- etc .. 
} 
  
setTimer ( function() 
        guiSetText ( "namelbl", getPlayerName ( localPlayer ) ); 
        guiSetText ( "pinglbl", getPlayerPing ( localPlayer ) ); 
        guiSetText ( "moneylbl", getPlayerMoney ( localPlayer ) ); 
    end, 1000, 0 
); 

but the DebugScript is Mentioning the "namelbl" , "pinglbl" , "moneylbl"

is it missing something ? Or i am Setting Timer in the Wrong Location ? ..

Link to comment

Not Tested.

    wndMain = { 
        'wnd', 
           text = 'Player Panel', 
        x = 10, 
        y = 150, 
        width = 277, 
        controls = { 
             element1 = {'lbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
            element2 = {'lbl', text = 'Your Ping: ' .. getPlayerPing(g_Me)) .. ' '}, 
            {'br'}, 
            element3 = {'lbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
    } 
      
    setTimer ( function() 
            guiSetText ( element1, ""..getPlayerName ( localPlayer ) ); 
            guiSetText ( element2, ""..getPlayerPing ( localPlayer ) ); 
            guiSetText ( element3, ""..getPlayerMoney ( localPlayer ) ); 
        end, 1000, 0 
    ) 

Really ??

guiSetText ( "namelbl", getPlayerName ( localPlayer ) ); 

or wiki Introduction

guiSetText ( element1, ""..getPlayerName ( localPlayer ) ); 

Link to comment
Not Tested.
    wndMain = { 
        'wnd', 
           text = 'Player Panel', 
        x = 10, 
        y = 150, 
        width = 277, 
        controls = { 
             element1 = {'lbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
            element2 = {'lbl', text = 'Your Ping: ' .. getPlayerPing(g_Me)) .. ' '}, 
            {'br'}, 
            element3 = {'lbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
    } 
      
    setTimer ( function() 
            guiSetText ( element1, ""..getPlayerName ( localPlayer ) ); 
            guiSetText ( element2, ""..getPlayerPing ( localPlayer ) ); 
            guiSetText ( element3, ""..getPlayerMoney ( localPlayer ) ); 
        end, 1000, 0 
    ) 

Really ??

guiSetText ( "namelbl", getPlayerName ( localPlayer ) ); 

or wiki Introduction

guiSetText ( element1, ""..getPlayerName ( localPlayer ) ); 

Ohh oops, you're right. the element names shouldn't be string values but actual elements, I'm way too used to my own system. :lol:

Link to comment

@tosfera & Nicktim.

Well ..

The GUI Object set's the Location of the 3 Label's to the Down (Footer) Of the Window

Here's an Image: *BEFORE* > *AFTER*

The Timer Func Didn't Worked at All ..

The Full Code:

wndMain = { 
    'wnd', 
       text = 'Player Panel', 
    x = 10, 
    y = 150, 
    width = 277, 
    controls = { 
                element1 = {'lbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
                element2 = {'lbl', text = 'Your Ping: ' .. getPlayerPing(g_Me)) .. ' '}, 
                {'br'}, 
                element3 = {'lbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
                -- etc .. 
    }, 
    oncreate = mainWndShow, 
    onclose = mainWndClose 
} 
  
setTimer ( function() 
            guiSetText ( element1, ""..getPlayerName ( localPlayer ) ); 
            guiSetText ( element2, ""..getPlayerPing ( localPlayer ) ); 
            guiSetText ( element3, ""..getPlayerMoney ( localPlayer ) ); 
        end, 1000, 0 
    ) 

Remember I am using this code in Client Side.

Link to comment

try this

setTimer( 
function() 
     guiSetText (getControl(wndMain,"element1"), "Your Name: "..getPlayerName(localPlayer)); 
     guiSetText (getControl(wndMain,"element2"), "Your Ping: "..getPlayerPing(localPlayer)); 
     guiSetText (getControl(wndMain,"element3"), "Your Money: "..getPlayerMoney(localPlayer)); 
end, 1000, 0 ) 
Link to comment

@MoDeR2014

Still Gives Warnings ..

Bad argument @ 'guiSetText' [Expected gui-element at argument 1, got boolean] 

Full Code:

wndMain = { 
    'wnd', 
       text = '                                              لوحة تحكم الاعب                                                 ', 
    x = 10, 
    y = 150, 
    width = 277, 
    controls = { 
                element1 = {'lbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
        element2 = {'lbl', text = 'Your Ping: ' .. getPlayerPing(g_Me) .. ' '}, 
        {'br'}, 
        element3 = {'lbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
        {'br'}, 
        -- etc .. 
    }, 
    oncreate = mainWndShow, 
    onclose = mainWndClose 
} 
  
setTimer( 
function() 
     guiSetText (getControl(wndMain,"element1"), "Your Name: "..getPlayerName(localPlayer)); 
     guiSetText (getControl(wndMain,"element2"), "Your Ping: "..getPlayerPing(localPlayer)); 
     guiSetText (getControl(wndMain,"element3"), "Your Money: "..getPlayerMoney(localPlayer)); 
end, 1000, 0 ) 

Please Help :(

Link to comment
@MoDeR2014

Still Gives Warnings ..

Bad argument @ 'guiSetText' [Expected gui-element at argument 1, got boolean] 

Full Code:

wndMain = { 
    'wnd', 
       text = '                                              لوحة تحكم الاعب                                                 ', 
    x = 10, 
    y = 150, 
    width = 277, 
    controls = { 
                element1 = {'lbl', text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
        element2 = {'lbl', text = 'Your Ping: ' .. getPlayerPing(g_Me) .. ' '}, 
        {'br'}, 
        element3 = {'lbl', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
        {'br'}, 
        -- etc .. 
    }, 
    oncreate = mainWndShow, 
    onclose = mainWndClose 
} 
  
setTimer( 
function() 
     guiSetText (getControl(wndMain,"element1"), "Your Name: "..getPlayerName(localPlayer)); 
     guiSetText (getControl(wndMain,"element2"), "Your Ping: "..getPlayerPing(localPlayer)); 
     guiSetText (getControl(wndMain,"element3"), "Your Money: "..getPlayerMoney(localPlayer)); 
end, 1000, 0 ) 

Please Help :(

wndMain = { 
    'wnd', 
       text = '                                              لوحة تحكم الاعب                                                 ', 
    x = 10, 
    y = 150, 
    width = 277, 
    controls = { 
        {'lbl', id='element1',  text = 'Your Name: ' .. getPlayerName(g_Me) .. ' '}, 
        {'lbl', id='element2', text = 'Your Ping: ' .. getPlayerPing(g_Me) .. ' '}, 
        {'br'}, 
        {'lbl', id='element3', text = 'Your Money: ' .. getPlayerMoney(g_Me) .. ' $'}, 
        {'br'}, 
        -- etc .. 
    }, 
    oncreate = mainWndShow, 
    onclose = mainWndClose 
} 
  
setTimer( 
function() 
     guiSetText (getControl(wndMain,"element1"), "Your Name: "..getPlayerName(localPlayer)); 
     guiSetText (getControl(wndMain,"element2"), "Your Ping: "..getPlayerPing(localPlayer)); 
     guiSetText (getControl(wndMain,"element3"), "Your Money: "..getPlayerMoney(localPlayer)); 
end, 1000, 0 ) 

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...