Jump to content

guiGridListGetSelectedItem - not working as expected


crismar

Recommended Posts

Posted

function craftPanel() 
        craft = guiCreateWindow(243, 296, 526, 241, "Panoul de Constructie", false) 
        guiWindowSetSizable(craft, false) 
        guiSetVisible(craft, false) 
         
        craftItems = guiCreateGridList(9, 27, 144, 204, false, craft) 
        guiGridListSetScrollBars(craftItems, false, false) 
        guiGridListAddColumn(craftItems, "Item", 0.9) 
        guiGridListAddRow(craftItems) 
        guiGridListSetItemText(craftItems, 0, 1, "CZ-550", false, false) 
        craftReq = guiCreateMemo(163, 79, 354, 90, "", false, craft) 
        craftName = guiCreateLabel(163, 27, 354, 17, "Item:", false, craft) 
        guiSetFont(craftName, "default-bold-small") 
        craftQ = guiCreateLabel(163, 44, 354, 17, "Cantitate:", false, craft) 
        guiSetFont(craftQ, "default-bold-small") 
        craftUseless = guiCreateLabel(163, 61, 354, 17, "Materiale Necesare:", false, craft) 
        guiSetFont(craftUseless, "default-bold-small") 
        guiLabelSetColor(craftUseless, 255, 0, 0) 
        craftGo = guiCreateButton(343, 177, 174, 54, "Construieste", false, craft) 
        guiSetFont(craftGo, "default-bold-small") 
        guiSetProperty(craftGo, "NormalTextColour", "FF00FF00") 
        craftNote = guiCreateLabel(165, 175, 168, 56, "- Nu oferim materiale inapoi;\n- Sansa de succes la constructie este de 40%!", false, craft) 
        guiSetFont(craftNote, "default-bold-small") 
        guiLabelSetHorizontalAlign(craftNote, "left", true)   
        local craftPick = guiGridListGetSelectedItem(craftItems) 
        addEventHandler("onClientGUIClick", craftGo, craftCheck) 
end 
addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), craftPanel) 
  
function showMenu() 
    if guiGetVisible(craft) == true then 
    guiSetVisible(craft, false) 
    showCursor(false) 
    else 
    guiSetVisible(craft, true) 
    showCursor(true) 
    end 
end 
addCommandHandler("craft", showMenu, false) 
  
function craftCheck() 
    outputChatBox(craftPick) 
end 

Howdy, I have this GUI, basically I want to make a crafting system. I managed to pull it around with commands really quick, but I thought it's time to take advantage of MTA GUIs... then I had a nasty surprise, even simplest stuffs became hard :cry:

I'm at the moment stuck with getting the value of a selected row.

What I want to do is: when the

craftGo 

button is clicked, function

craftCheck() 

is triggered and will output in the chatbox the value of the selected item (in this case CZ-550)

At the moment my script outputs 'nil' even if I select the CZ-550 row. Any ideas ? :/

Posted

Nevermind, figured out by myself, guiGridListGetSelectedItem returns row and column.

also so the script was supposed to have:

local row, column = guiGridListGetSelectedItem(craftItems) 

And the local was to be placed in the craftCheck function.

Posted if anyone encounters the same problem.

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