guiCreateComboBox | Multi Theft Auto: Wiki Skip to content

guiCreateComboBox

Client-side
Server-side
Shared

This page is incomplete! Help wanted!

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


This function creates a combobox GUI element, which you can compare to a gridlist with a dropdown feature.

Note

The height of a combobox must be enough to fit the drop down menu, else the drop down won't appear. See guiComboBoxAdjustHeight to give your combobox the correct height.

Syntax

guiCreateComboBox ( )

Code Examples

client

This example creates a combo box in the center of the screen with all server vehicles on it.

addEventHandler ("onClientResourceStart",resourceRoot,function()
local screenWidth, screenHeight = guiGetScreenSize()
local windowWidth, windowHeight = 200,100
local left = screenWidth/2 - windowWidth/2
local top = screenHeight/2 - windowHeight/2
local vehiclesComboBox = guiCreateComboBox ( left, top, windowWidth,windowHeight, "Vehicle Names", false ) -- We create a combo box.
for index, vehicle in ipairs ( getElementsByType ( "vehicle" ) ) do -- We loop through all vehicles.
guiComboBoxAddItem ( vehiclesComboBox, getVehicleName ( vehicle ) ) -- We add the vehicle name to our combo box.
end
end)

See Also

GUI Functions