CallumD Posted December 31, 2009 Share Posted December 31, 2009 My spawn menu is coded pretty badly so the client-side is about 1,000 lines big. So I've decided to shrink it down. I thought of making custom elements server-side and using them for the menu's contents. I don't get why the code below dosn't work (only snippets of the whole code of course). Server-side: city1 = createElement ( "city", "Los Santos" ) city2 = createElement ( "city", "Flint County" ) -- etc, etc Client-side: local cities = getElementsByType ( "city" ) for city, cityName in ipairs ( cities ) do local row = guiGridListAddRow ( cityGridList ) guiGridListSetItemText ( cityGridList, row, cityColumn, cityName, false, false ) end On the other hand, could anybody suggest a better way of storing the grid lists items? Preferably a way that clients don't download it. Link to comment
eAi Posted December 31, 2009 Share Posted December 31, 2009 That seems a good idea, you could store your elements in a map file. As to why it isn't working - do you get any errors in either the client or server-side consoles? Link to comment
CallumD Posted December 31, 2009 Author Share Posted December 31, 2009 No errors at all, just the grid list is empty. Link to comment
subenji99 Posted December 31, 2009 Share Posted December 31, 2009 It's a simple solution, and you'll kick yourself for this. local cities = getElementsByType ( "city" ) This is going to return an element table as you expect, but the values will not be the element ID's but the element objects: cities = { 1 = element:"memory pointer" 2 = element:"another memory pointer" ... } --the actual pointer memory address doesn't matter - you're getting element objects is all you need to concern yourself with All you need to do is fetch the "id" Element Data from that element object: for city, cityElem in ipairs ( cities ) do local row = guiGridListAddRow ( cityGridList ) local cityName = getElementData ( cityElem, "id" ) guiGridListSetItemText ( cityGridList, row, cityColumn, cityName, false, false ) end Have fun. 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