Jump to content

How to do this..


Recommended Posts

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

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 by Guest
Link to comment

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

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

Hm, it should.. works for me. This is what you wanted right? also check /debugscript

eqntc9.png

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

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

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