ServersYour serverFor creatorsForumFAQDocumentationSecurity
Download the launcher
  1. Documentation
  2. Client functions
  3. guiCreateComboBox

Function

guiCreateComboBox

Creates a drop-down list. Choosing an item fires onClientGUIComboBoxAccepted.

Syntax

gui-combobox guiCreateComboBox(float x, float y, float width, float height, string caption, bool relative [, element parent = nil])

Arguments

xfloat
X position.
yfloat
Y position.
widthfloat
Width.
heightfloat
Height of the opened list.
captionstring
Text when nothing is selected.
relativebool
Relative values.Optional in MTA:SA: bool relative = false
parentelement, optional = nil
Parent.

Differences from MTA:SA

  • Arguments in a different colour differ from MTA:SA.

In MTA:SA

guiCreateComboBox(float x, float y, float width, float height, string caption, bool relative = false, gui-element parent = nil)

Returns

The list.

Example

local combo = guiCreateComboBox(20, 20, 200, 150, "Wybierz pogodę", false)
for _, name in ipairs({ "Słońce", "Chmury", "Deszcz" }) do
    guiComboBoxAddItem(combo, name)
end
addEventHandler("onClientGUIComboBoxAccepted", combo, function()
    local i = guiComboBoxGetSelected(combo)
    outputChatBox("Wybrano: " .. guiComboBoxGetItemText(combo, i))
end, false)

See also