DgsComboBoxSetItemColor

From Multi Theft Auto: Wiki

This function changes the color of a comboBox item.

Syntax

bool dgsComboBoxSetItemColor ( element comboBox, int item, int color)

Required Arguments

  • comboBox: The combo box element
  • item: Item ID
  • color: The amount of the color (0-‭4294967295‬)

Returns

Returns true if the item color was set successfully, false otherwise.

Example

This example creates a player list on the right of the screen and fills it with players online and sets the combo box item color according to their nametag color.

DGS = exports.dgs

function createPlayerComboBox ( )
	--Create the grid list element
	local playerComboBox = DGS:dgsCreateComboBox ( 0.80, 0.10, 0.15, 0.60,"Select a player", true )
	for id, player in ipairs ( getElementsByType ( "player" ) ) do
		local item = DGS:dgsComboBoxAddItem( playerComboBox )
		local r, g, b = getPlayerNametagColor ( player ) -- We get the player nametag color.
		DGS:dgsComboBoxSetItemText ( playerComboBox , item, getPlayerName ( player ) )
		DGS:dgsComboBoxSetItemColor ( playerComboBox , item, tocolor( r, g, b, 255 ) ) -- We set the grid list item color to the returned values of getPlayerNametagColor.
	end
end
addEventHandler ( "onClientResourceStart", resourceRoot, createPlayerList )

See Also

Multi Language Supports

Animation

3D Interface

3D Text

Arrow List

Browser

Button

Check Box

Combo Box

Edit

Ellipse Detect Area

Detect Area

Grid List

Image

Memo

Label

Progress Bar

Radio Button

Scroll Bar

Scroll Pane

Switch Button

Tab Panel

Window

Plugin

Media Browser

Rounded Rectangle

Color Picker

Blur Box

Effect 3D