Charlie_Jefferson Posted April 18, 2012 Share Posted April 18, 2012 rbnames = { ["roadright"] = "Small roadblock", ["helix_barrier"] = "Big Street Roadblock", ["roadworkbarrier1"] = "Sidewalk Roadblock", ["roadbarrier4"] = "Barrier", ["roadbarrier3"] = "Detour sign", ["roadbarrier6"] = "Small barrier" } GUIEditor_Button = {} rbswindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) guiWindowSetSizable(rbswindow,false) accp = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbswindow) cls = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbswindow) rbsmenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbswindow) guiGridListSetSelectionMode(rbsmenu,2) guiGridListAddColumn(rbsmenu,"Roadblocks",0.12) for i = 1, 6 do guiGridListAddRow(rbsmenu) end Got this, obviously client-side. I'd like to make it so that the gridlist takes the names from the table, the ones after "=" and use them, as in make the grid list row text to them. How can I do that? Don't edit the script, just tell me how, I'd like to learn myself. Link to comment
Absence2 Posted April 18, 2012 Share Posted April 18, 2012 (edited) click: https://wiki.multitheftauto.com/wiki/GuiCreateGridList there's really no point in helping you learn here. (It's aldready written on the wiki, explained in detail too). You can simply copy-paste from there. this is what you need: for key,weaponName in pairs(shotguns) do --add a new row to our gridlist each time local row = guiGridListAddRow ( spawnScreenGridList ) --get our new row --next, we set that rows text to the weapon name. Column is 1 since the "Shotguns" column was created first. guiGridListSetItemText ( spawnScreenGridList, row, 1, weaponName, false, false ) This is how to do it: (P.S: Don't open it if you want to try yourself) rbNames = { ["roadright"] = "Small roadblock", ["helix_barrier"] = "Big Street Roadblock", ["roadworkbarrier1"] = "Sidewalk Roadblock", ["roadbarrier4"] = "Barrier", ["roadbarrier3"] = "Detour sign", ["roadbarrier6"] = "Small barrier" } rbsWindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) guiWindowSetSizable(rbsWindow,false) acceptButton = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbsWindow) closeButton = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbsWindow) rbsMenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbsWindow) guiGridListSetSelectionMode(rbsMenu,2) guiGridListAddColumn(rbsMenu,"Roadblocks",0.12) for key,rbNames in pairs(rbNames) do local row = guiGridListAddRow ( rbsMenu ) guiGridListSetItemText ( rbsMenu, row, 1, rbNames, false, false ) end for i = 1, 6 do guiGridListAddRow(rbsMenu) end Edited April 18, 2012 by Guest Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 (edited) I know it's written on the wiki. I thought it's different though. This is the scripting section, I can post whatever I want as long as it involves scripting. Edited April 18, 2012 by Guest Link to comment
Absence2 Posted April 18, 2012 Share Posted April 18, 2012 thing is, what most people fail to do when trying to learn something, for an example, Lua. They come here because they haven't tried enough yet. If you read it a few more times then tried it yourself, you would understand. You would then get an idea how it works, for this and other things. It's very pattern-like. Once you get a hang of it, you'll quickly understand many other things once you've came to that specific part. Also, I wont prevent you for posting here for help. I did the same thing. Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 thing is, what most people fail to do when trying to learn something, for an example, Lua. They come here because they haven't tried enough yet. If you read it a few more times then tried it yourself, you would understand. You would then get an idea how it works, for this and other things. It's very pattern-like. Once you get a hang of it, you'll quickly understand many other things once you've came to that specific part.Also, I wont prevent you for posting here for help. I did the same thing. Okay. Thanks for clearing that up. Also, it doesn't work for some reason. I tried copying the spoiler script too. Link to comment
Absence2 Posted April 18, 2012 Share Posted April 18, 2012 alright, so what exactly are you trying to achieve now and what didn't work? I just included your table in the gridList Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 alright, so what exactly are you trying to achieve now and what didn't work? I just included your table in the gridList The GUI appears, but the gridlist rows aren't filled. The same thing I was trying to achieve a minute ago. Link to comment
Absence2 Posted April 18, 2012 Share Posted April 18, 2012 try this: rbNames = { ["roadright"] = "Small roadblock", ["helix_barrier"] = "Big Street Roadblock", ["roadworkbarrier1"] = "Sidewalk Roadblock", ["roadbarrier4"] = "Barrier", ["roadbarrier3"] = "Detour sign", ["roadbarrier6"] = "Small barrier" } rbsWindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) guiWindowSetSizable(rbsWindow,false) acceptButton = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbsWindow) closeButton = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbsWindow) rbsMenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbsWindow) guiGridListSetSelectionMode(rbsMenu,2) guiGridListAddColumn(rbsMenu,"Roadblocks",0.5) for key,rbNames in pairs(rbNames) do local row = guiGridListAddRow ( rbsMenu ) guiGridListSetItemText ( rbsMenu, row, 1, rbNames, false, false ) end for i = 1, 6 do guiGridListAddRow(rbsMenu) end Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 Now the menu doesn't show up at all(the GUI window). Edit: I made it show up, but the gridlist still isn't populated. Link to comment
Absence2 Posted April 18, 2012 Share Posted April 18, 2012 Hm, it should.. works for me. This is what you wanted right? also check /debugscript Did you copy the full code or just this part: for key,rbNames in pairs(rbNames) do local row = guiGridListAddRow ( rbsMenu ) guiGridListSetItemText ( rbsMenu, row, 1, rbNames, false, false ) end because if you did, change rbNames & rbsMenu to whatever you had earlier Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 I did change em, but it still doesn't show up. Here's the code I've got. rbnames = { ["roadright"] = "Small roadblock", ["helix_barrier"] = "Big Street Roadblock", ["roadworkbarrier1"] = "Sidewalk Roadblock", ["roadbarrier4"] = "Barrier", ["roadbarrier3"] = "Detour sign", ["roadbarrier6"] = "Small barrier" } function cGUI() showCursor(true) toggleAllControls(true) rbsWindow = guiCreateWindow(0.3391,0.2832,0.3125,0.4688,"Roadblock System",true) guiWindowSetSizable(rbsWindow,false) acceptButton = guiCreateButton(0.1075,0.8813,0.3225,0.0854,"Accept",true,rbsWindow) closeButton = guiCreateButton(0.57,0.8813,0.3225,0.0854,"Close",true,rbsWindow) rbsMenu = guiCreateGridList(0.11,0.1292,0.785,0.725,true,rbsWindow) guiGridListSetSelectionMode(rbsMenu,2) guiGridListAddColumn(rbsMenu,"Roadblocks",0.90) for key,rbNames in pairs(rbnames) do local row = guiGridListAddRow ( rbsMenu ) guiGridListSetItemText ( rbsMenu, row, 1, rbnames, false, false ) end for i = 1, 6 do guiGridListAddRow(rbsMenu) end end addCommandHandler("rb", cGUI) Link to comment
Charlie_Jefferson Posted April 18, 2012 Author Share Posted April 18, 2012 Oh, right. I didn't notice it's capitalized. It works now, thank you. Link to comment
Michael# Posted April 18, 2012 Share Posted April 18, 2012 One thing, for what is that? for i = 1, 6 do guiGridListAddRow(rbsMenu) end Why is that needed here if the rows are added in the first loop? 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