Jump to content

Getting player money from gridlist ?


FuriouZ

Recommended Posts

Okay,me again

I creating phone to my server and i have an question ,is possible to put functions like

getPlayerMoney 

to gridlist and if then how ?

Pic:

mta-screen_2013-05-12_18-20-20.png

Here's my code:

GUIEditor.gridlist[1] = guiCreateGridList(19, 57, 250, 465, false, GUIEditor.staticimage[1]) 
        guiGridListAddColumn(GUIEditor.gridlist[1], "Your current stats are below", 0.9) 
        for i = 1, 3 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiSetVisible( GUIEditor.gridlist[1], false ) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "-", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "-", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "-", false, false)  

PS: i am newibe in scripting,i try to figure out how much i can from wiki,but if i can't then i'll post here..

Link to comment

You can make a function then if the gui visible then use :

guiGridListSetItemText 

For Ex :

-- # Client Side 
function SetGridMoneyText   (   ) 
     for i = 1,3 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "- Money : "..getPlayerMoney(localPlayer).." $", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "-", false, false) -- Add any thing you want name ping..etc 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "-", false, false) -- too 
end 
  
bindKey("F1","down", 
    function    ( ) 
        if guiGetVisible ( GUIEditor.gridlist[1] ) then 
            guiSetVisible ( GUIEditor.gridlist[1] , false ) 
            showCursor ( false ) 
        else 
            guiSetVisible ( GUIEditor.gridlist[1] , true ) 
            SetGridMoneyText(   ) 
            showCursor ( true ) 
        end 
    end 
) 

Link to comment
As what i do you can see when the gui visible the money will refresh automatic or use :
setTimer 

Closing and opening phone doesn't refresh,but can you explain more please,how to refresh them via setTimer ?

Anyway,thanks for helping

Here is my phone :)

mta-screen_2013-05-12_19-22-53.png

mta-screen_2013-05-12_19-22-56.png

(messaging and calculator arent done jet)

Link to comment
-- # Client Side 
  
setTimer ( 
    function    (   ) 
     for i = 1,3 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "- Money : "..getPlayerMoney(localPlayer).." $", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "-", false, false) -- Add any thing you want name ping..etc 
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "-", false, false) -- too 
    end,50,0 
) 
  

Try it.

Link to comment

Doesn't work :/

I don't wan't put full code here,but this is first part:

GUIEditor = { 
    button = {}, 
    staticimage = {}, 
    label = {}, 
    gridlist = {}    
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    function() 
        --PHONE 
        GUIEditor.staticimage[1] = guiCreateStaticImage(519, 0, 289, 580, "img/phone.png", false) 
  

Then comes:

Images,buttons etc...

and then this part:

        GUIEditor.gridlist[1] = guiCreateGridList(19, 57, 250, 465, false, GUIEditor.staticimage[1])     
        guiGridListAddColumn(GUIEditor.gridlist[1], "Your current stats are below", 0.9) 
        for i = 1, 5 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiSetVisible( GUIEditor.gridlist[1], false ) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Name : "..getPlayerName(localPlayer).."", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Money : "..getPlayerMoney(localPlayer).." €", false, false)   
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Health : "..getElementHealth(localPlayer).." %", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Amour : "..getPedArmor(localPlayer).." %", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "PING : "..getPlayerPing(localPlayer).."", false, false)                 
    end 
) 

Last ")" closes the first part "addEventHandler("onClientResourceStart", resourceRoot,

    function()"

I did like this :

GUIEditor = { 
    button = {}, 
    staticimage = {}, 
    label = {}, 
    gridlist = {}    
} 
addEventHandler("onClientResourceStart", resourceRoot, 
    setTimer ( 
    function() 

and closed it :

        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "PING : "..getPlayerPing(localPlayer).."", false, false)                 
    end,50,0 
) 
end 

I tryed to add "setTimer (" before to "for i = 1, 5 do" but it didn't work

Thanks for helping i know that i am an idiot ,but i am newibe in scripting anyway :lol:

Link to comment
GUIEditor.gridlist[1] = guiCreateGridList(19, 57, 250, 465, false, GUIEditor.staticimage[1])     
guiGridListAddColumn(GUIEditor.gridlist[1], "Your current stats are below", 0.9) 
  
setTimer( 
    function ( ) 
       for i = 1, 5 do 
            guiGridListAddRow(GUIEditor.gridlist[1]) 
        end 
        guiGridListSetItemText(GUIEditor.gridlist[1], 0, 1, "Name : "..getPlayerName(localPlayer).."", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 1, 1, "Money : "..getPlayerMoney(localPlayer).." €", false, false)   
        guiGridListSetItemText(GUIEditor.gridlist[1], 2, 1, "Health : "..getElementHealth(localPlayer).." %", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 3, 1, "Amour : "..getPedArmor(localPlayer).." %", false, false) 
        guiGridListSetItemText(GUIEditor.gridlist[1], 4, 1, "PING : "..getPlayerPing(localPlayer).."", false, false)          
    end,50,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...