guiComboBoxSetItemText | Multi Theft Auto: Wiki Skip to content

guiComboBoxSetItemText

Client-side
Server-side
Shared

Pair: guiComboBoxGetItemText

This function changes the text of a combobox item.

OOP Syntax Help! I don't understand this!

Syntax

bool guiComboBoxSetItemText ( ​gui-combobox comboBox, ​int itemId, ​string text )
Required arguments
  • comboBox: The combobox containing the item you're interested in.
  • itemId: The index of the item. Indexing starts at 0.
  • text: The text you want to set for the item.

Returns

Returns true if the text was set successfully, false otherwise.

  • bool: result

Code Examples

client

This changes the text of the selected item using command setText.

local comboBox = guiCreateComboBox(100, 150, 200, 300, "", false)
guiComboBoxAddItem(comboBox, "First item")
guiComboBoxAddItem(comboBox, "Second item")
addCommandHandler("setText", function(cmd, text)
local item = guiComboBoxGetSelected(comboBox)
if (item == -1) then
outputChatBox("No item selected.")
return
end
guiComboBoxSetItemText(comboBox, item, text)
end)

See Also

GUI Functions