Jump to content

Check what list row I've choose.


Recommended Posts

I've created a grid list and added a button. What I want to do is after I click the button check what row in the gridlist has been choosen. 

Also, the same but for EditBoxes.

 

About the gridlists, I saw this link (https://wiki.multitheftauto.com/wiki/GuiGridListGetSelectedItem), but it's really confusing. I can't find anything about the EditBoxes.

 

Thanks for the help.

EditBox. I want the code to see what I've written on both EditBoxes after I click buttonE, and give me a weapon with the ID and bullets I've written on the EditBox. You don't need to tell me how to make the second part of that sentence, I'll try to do it by myself, but I can't really understand how to check what's written in the EditBoxes.

function armasJanela()
    local janelaArmas = guiCreateWindow (0.015, 0.18, 0.10, 0.2, "Armas", true)
    showCursor(true)
    guiSetInputMode("no_binds_when_editing")
    guiWindowSetSizable(janelaArmas, false)

    IDArma = guiCreateEdit(0.1, 0.12, 0.8, 0.15, "ID da Arma [0-46]", true, janelaArmas)
    guiEditSetMaxLength (IDArma, 20)
    Balas = guiCreateEdit(0.1, 0.30, 0.8, 0.15, "Balas [0-10000]", true, janelaArmas)
    guiEditSetMaxLength (Balas, 6)

    buttonC = guiCreateButton(0.5, 0.87, 0.4, 0.6, "Cancelar", true, janelaArmas)
    addEventHandler ( "onClientGUIClick", buttonC, cancelamentoJanelaArmas)
    buttonE = guiCreateButton(0.1, 0.87, 0.4, 0.6, "Escolher", true, janelaArmas)
    addEventHandler ("onClientGUIClick", buttonE, escolhaJanelaArmas) 
end
addCommandHandler("armas", armasJanela)

function cancelamentoJanelaArmas()
    local destruirArmasJanela = getResourceGUIElement(getThisResource())
    destroyElement(destruirArmasJanela)
    showCursor(false)
end

function escolhaJanelaArmas()
    local textoIDArma = guiGetText(IDArma)
    outputChatBox(textoIDArma)
    givePedWeapon(localPlayer, textoIDArma, 999, true)
    local destruirArmasJanela = getResourceGUIElement(getThisResource())
    destroyElement(destruirArmasJanela)
    showCursor(false)
end

 

GridLists. I want to get what row was selected after I pressed the buton2 and then read a function based on what row was selected.

function janelaJarda (commandName)
    local jardaJanela = guiCreateWindow (0.25, 0.15, 0.20, 0.4, "Esteróides", true) 
    local lista = guiCreateGridList (0, 0.1, 1, 0.75, true, jardaJanela)
    guiWindowSetMovable(jardaJanela, true)
    guiWindowSetSizable(jardaJanela, false)
    showCursor(true)

    coluna1 = guiGridListAddColumn(lista, "Nome", 0.49)
    coluna2 = guiGridListAddColumn(lista, "Propriedades", 0.49)

    
    guiGridListAddRow(lista, "Esteróide Máximo", "Jarda potentíssima")
    guiGridListAddRow(lista, "Esteróide Segundo", "Jarda muito potente")
    button = guiCreateButton(0.6, 0.87, 0.3, 0.1, "Cancelar", true, jardaJanela)
    addEventHandler ( "onClientGUIClick", button, cancelamentoJardaJanela)

    button2 = guiCreateButton(0.1, 0.87, 0.3, 0.1, "Escolher", true, jardaJanela)
    addEventHandler ("onClientGUIClick", button2, escolhaJarda)

end    
addCommandHandler ("jarda", janelaJarda) 

function cancelamentoJardaJanela()
    local destruirJardaJanela = getResourceGUIElement(getThisResource())
    destroyElement(destruirJardaJanela)
    showCursor(false)
end

function escolhaJarda()
    local destruirJardaJanela = getResourceGUIElement(getThisResource())
    destroyElement(destruirJardaJanela)
end

function escolhaJarda()
end

 

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