NotAvailable Posted July 2, 2011 Share Posted July 2, 2011 Hi, I'm creating a achievement system. But i have 0 experience with Gridlists. Picture: 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
Klesh Posted July 3, 2011 Share Posted July 3, 2011 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
falseprophet Posted July 3, 2011 Share Posted July 3, 2011 He's asking a question on how to change the text with the gridlist widget or whichever widgit he is using, I guess. Link to comment
Castillo Posted July 3, 2011 Share Posted July 3, 2011 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
NotAvailable Posted July 3, 2011 Author Share Posted July 3, 2011 The purpose of this topic is, that I need help with GUI gridlists. How can i show the achievements in the gridlists? and how to change the locked text when you achieve it? If someone could help me i would really appreciate that. Thanks! Link to comment
Castillo Posted July 3, 2011 Share Posted July 3, 2011 Well, in my system I store the data and then I check which are unlocked and which aren't. Link to comment
NotAvailable Posted July 3, 2011 Author Share Posted July 3, 2011 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
Buffalo Posted July 3, 2011 Share Posted July 3, 2011 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
NotAvailable Posted July 3, 2011 Author Share Posted July 3, 2011 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
Castillo Posted July 3, 2011 Share Posted July 3, 2011 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
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