Jump to content

Combobox


franku

Recommended Posts

Simple example:

  
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) 
  
addCommandHandler("gettext", function (command)  
    local item = guiComboBoxGetSelected(vehiclesComboBox) 
    local text = guiComboBoxGetItemText(vehiclesComboBox, item) 
    outputChatBox("Currently selected item with ID: " .. tostring(item) .. " and with text: " .. text) 
end) 
  

Now go ig, start this and type /gettext

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