guiComboBoxGetSelected | Multi Theft Auto: Wiki Skip to content

guiComboBoxGetSelected

Client-side
Server-side
Shared

Pair: guiComboBoxSetSelected

Manual Review Required

Please finish this page using the corresponding Old Wiki article. Go to Contribution guidelines for more information.


This function returns the index of the selected combobox item.

OOP Syntax Help! I don't understand this!

  • Method: guicombobox:getSelected(...)
  • Variable: .selected

Syntax

int guiComboBoxGetSelected ( element comboBox )
Required Arguments
  • comboBox: the combobox you want to know the selected item index of

Returns

  • int: value

Returns the index of the selected item if the specified combobox is valid and has a selected item, -1 if no item is selected, nil otherwise.

Code Examples

shared

This example outputs selected item's text and ID to the chat.

addCommandHandler("getSelected",
function (command)
local item = guiComboBoxGetSelected(comboBox)
local text = guiComboBoxGetItemText(comboBox, item)
outputChatBox("Currently selected item with ID: " .. tostring(item) .. " and with text: " .. text)
end)

See Also

GUI Functions