FuriouZ Posted May 12, 2013 Posted May 12, 2013 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: 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..
iPrestege Posted May 12, 2013 Posted May 12, 2013 Yes you want to get players money or just the localPlayer ? guiGridListSetItemText getPlayerMoney
iPrestege Posted May 12, 2013 Posted May 12, 2013 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 )
FuriouZ Posted May 12, 2013 Author Posted May 12, 2013 Thank you! But how to refresh money without restarting script ?
iPrestege Posted May 12, 2013 Posted May 12, 2013 As what i do you can see when the gui visible the money will refresh automatic or use : setTimer
FuriouZ Posted May 12, 2013 Author Posted May 12, 2013 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 (messaging and calculator arent done jet)
iPrestege Posted May 12, 2013 Posted May 12, 2013 -- # 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.
FuriouZ Posted May 12, 2013 Author Posted May 12, 2013 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
iPrestege Posted May 12, 2013 Posted May 12, 2013 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 )
iPrestege Posted May 12, 2013 Posted May 12, 2013 You must put the resource in ACL Group "Admin". For what?
Sasu Posted May 12, 2013 Posted May 12, 2013 You must put the resource in ACL Group "Admin". For what? I confused. Sorry. I saw a getPlayerIP instead getPlayerPing. Sorry
myonlake Posted May 13, 2013 Posted May 13, 2013 Please do bare in mind that it is more wise to trigger a server side event to fetch the money server-side rather than client-side, since server/client-side money are not synchronized.
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