Jump to content

[HELP] GridList Refresh


Lalalu

Recommended Posts

Posted

Hello, I need your help. I created a Gridlist using guieditor, it basically shows if you have a coin type available, gold or silver. If don't have coins the text of the row will show a "0" in red color, if you have more than 1 then the amount you have will be shown in green color.

My problem is that this list does not update when i open the panel. If I don't have a coin the text will show 0, but if I give the coin to myself for example and then open my panel again the balance is not updated, it continues to show "0" unless I restart the script. I tried using "guiGridListClear" , but the list disappears completely.

Here is a small part of my gridList code:

 

SLOT1 = guiCreateTab("SLOT 1", TabWindow)
               
Gridlist_Slot1 = guiCreateGridList(10, 10, 684, 358, false, SLOT1)
colum = guiGridListAddColumn(Gridlist_Slot1, "SELECT", 0.5)
colum2 = guiGridListAddColumn(Gridlist_Slot1, "AVAILABLE", 0.2)

for i = 1, 2 do
guiGridListAddRow(Gridlist_Slot1)
end

local Gold = exports.Points_system:getPlayerGold(localPlayer)	
guiGridListSetItemText(Gridlist_Slot1, 0, 1, "Gold Insignia", false, false)
if Gold == 0 then guiGridListSetItemText(Gridlist_Slot1, 0, 2, ""..Gold, false, false) guiGridListSetItemColor(Gridlist_Slot1, 0, 2, 255, 0, 0, 255) end
if Gold >= 1 then guiGridListSetItemText(Gridlist_Slot1, 0, 2, ""..Gold, false, false) guiGridListSetItemColor(Gridlist_Slot1, 0, 2, 0, 255, 0, 255) end
		
local Silver = exports.Points_system:getPlayerSilver(localPlayer)			
guiGridListSetItemText(Gridlist_Slot1, 1, 1, "Silver Insignia", false, false)
if Silver == 0 then guiGridListSetItemText(Gridlist_Slot1, 1, 2, ""..Silver, false, false) guiGridListSetItemColor(Gridlist_Slot1, 1, 2, 255, 0, 0, 255) end
if Silver == 1 then guiGridListSetItemText(Gridlist_Slot1, 1, 2, ""..Silver, false, false) guiGridListSetItemColor(Gridlist_Slot1, 1, 2, 0, 255, 0, 255) end  

 

Posted

you need to create a function to update it.

like update the thing when you open the panel for example

yeah you dont need to use guiGridListClear if the row always 2

just update the value of that

  • Thanks 1

You gone learn today.

I work my ass off, but I still can't pay tho.

Posted (edited)

 

Add the part of the code where you put the data of the gridlist in the function where to make the panel visible and place a gridListClear() on top of it all.

function open()
    guiSetVisible(windows, true) 
   ------------------------------------
   guiGridListClear(Gridlist_Slot1)
   for i = 1, 2 do
guiGridListAddRow(Gridlist_Slot1)
end

local Gold = exports.Points_system:getPlayerGold(localPlayer)	
guiGridListSetItemText(Gridlist_Slot1, 0, 1, "Gold Insignia", false, false)
if Gold == 0 then guiGridListSetItemText(Gridlist_Slot1, 0, 2, ""..Gold, false, false) guiGridListSetItemColor(Gridlist_Slot1, 0, 2, 255, 0, 0, 255) end
if Gold >= 1 then guiGridListSetItemText(Gridlist_Slot1, 0, 2, ""..Gold, false, false) guiGridListSetItemColor(Gridlist_Slot1, 0, 2, 0, 255, 0, 255) end
		
local Silver = exports.Points_system:getPlayerSilver(localPlayer)			
guiGridListSetItemText(Gridlist_Slot1, 1, 1, "Silver Insignia", false, false)
if Silver == 0 then guiGridListSetItemText(Gridlist_Slot1, 1, 2, ""..Silver, false, false) guiGridListSetItemColor(Gridlist_Slot1, 1, 2, 255, 0, 0, 255) end
if Silver == 1 then guiGridListSetItemText(Gridlist_Slot1, 1, 2, ""..Silver, false, false) guiGridListSetItemColor(Gridlist_Slot1, 1, 2, 0, 255, 0, 255) end  
 

end 

 

Edited by alex17"
  • Thanks 1

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