Jump to content

[HELP]GUI Gridlist


Recommended Posts

Hi,

I'm creating a achievement system.

But i have 0 experience with Gridlists.

Picture:

30wkrcn.png

Could someone tell me when you earn a achievement on how to change the Locked text to Unlocked.

Here is the code:

local sWidth,sHeight = guiGetScreenSize() 
  
achs = { 
      "New Guy", 
      "Almost dead!", 
      "Chatter", 
      "Dead man!", 
      "All Achievements" 
} 
  
locked = { 
      "Locked", 
      "Unlocked" 
} 
  
  
addEventHandler("onClientResourceStart",resourceRoot, 
    function() 
     
      local guy = getLocalPlayer()  
  
      achWindow = guiCreateWindow(sWidth-540,sHeight-407,sWidth-440,sHeight-319,"Achievements Window",false) 
         
      guiWindowSetMovable ( achWindow, true ) 
      guiWindowSetSizable ( achWindow, false ) 
       
      achMemo = guiCreateMemo(19,197,319,64,"",false,achWindow) 
      guiMemoSetReadOnly(achMemo,true) 
       
      achGrid = guiCreateGridList(19,29,319,158,false,achWindow) 
       
  
            guiGridListSetItemColor(achGrid, row, 1, 255, 200, 0) 
            local row = guiGridListAddRow ( achGrid ) 
             
       
       
    guiGridListAddColumn(achGrid,"Achievements",0.3) 
    guiGridListAddColumn(achGrid,"Unlocked/Locked",0.3) 
     
    guiGridListSetSelectionMode ( achGrid, 2 ) 
       
  
      for key,achievement in pairs(achs) do 
            local row = guiGridListAddRow ( achGrid ) 
            guiGridListSetItemText ( achGrid, row, 1, achievement, false, false ) 
      end 
      row = 0 
      for key,achievement in pairs(locked) do 
            guiGridListSetItemText ( achGrid, row, 2, achievement, false, false ) 
            row = row + 1 
     
  
   end 
   end 
) 
  

regards,

Jesseunit

Link to comment

You post here for show your script? or becuase you have any problems or errors with the code?

If you are posting for show your scriptm this is not the correctly place you must post it on the resources topic or in community, Good luck!

Link to comment
You post here for show your script? or becuase you have any problems or errors with the code?

If you are posting for show your scriptm this is not the correctly place you must post it on the resources topic or in community, Good luck!

Your post is FULL off-topic, as you can see the topic title says "[HELP]GUI Gridlist", are you blind or something like that? or maybe just trying to increase your post count?

Link to comment
Well, in my system I store the data and then I check which are unlocked and which aren't.

Yes Castillo i was thinking about that to :)

I store the achievements with setAccountData

So if i check with

if (getAccountData(player,"Achievement: New Guy") == false ) then 

Then i set the gridlist text to Locked, But how do i change the gridlist text?

Cause guiGridListSetItemText is not working.

Link to comment

i would do something like

for i,aName in pairs(achs)do 
   local row = guiGridListAddRow ( achGrid ) 
   guiGridListSetItemText ( achGrid, row, 1, aName, false, false ) 
   if (getAccountData(player,"Achievement: "..aName) == false ) then -- its locked? 
         guiGridListSetItemText ( achGrid, row, 2, 'Locked', false, false ) 
   else 
         guiGridListSetItemText ( achGrid, row, 2, 'Unlocked', false, false ) 
   end 
end 

So there would be less overload, as it sets lock once and then theres no need for 2nd loop

Link to comment
i would do something like
for i,aName in pairs(achs)do 
   local row = guiGridListAddRow ( achGrid ) 
   guiGridListSetItemText ( achGrid, row, 1, aName, false, false ) 
   if (getAccountData(player,"Achievement: "..aName) == false ) then -- its locked? 
         guiGridListSetItemText ( achGrid, row, 2, 'Locked', false, false ) 
   else 
         guiGridListSetItemText ( achGrid, row, 2, 'Unlocked', false, false ) 
   end 
end 

So there would be less overload, as it sets lock once and then theres no need for 2nd loop

getAccountData is server-sided

Link to comment
i would do something like
for i,aName in pairs(achs)do 
   local row = guiGridListAddRow ( achGrid ) 
   guiGridListSetItemText ( achGrid, row, 1, aName, false, false ) 
   if (getAccountData(player,"Achievement: "..aName) == false ) then -- its locked? 
         guiGridListSetItemText ( achGrid, row, 2, 'Locked', false, false ) 
   else 
         guiGridListSetItemText ( achGrid, row, 2, 'Unlocked', false, false ) 
   end 
end 

So there would be less overload, as it sets lock once and then theres no need for 2nd loop

Fail? o_O.

Btw, I store my achievements in a SQLITE table.

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