<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/DgsMenuSetItemColor?action=history&amp;feed=atom</id>
	<title>DgsMenuSetItemColor - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/DgsMenuSetItemColor?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsMenuSetItemColor&amp;action=history"/>
	<updated>2026-05-03T21:52:01Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=DgsMenuSetItemColor&amp;diff=82214&amp;oldid=prev</id>
		<title>Mohab: Created page with &quot;{{Client function}} __NOTOC__ This function sets the color of a specific menu item. You can set both the normal and hover colors for the item.  ==Syntax== &lt;syntaxhighlight lang=&quot;lua&quot;&gt; bool dgsMenuSetItemColor ( element menu, int uniqueID, int r, int g, int b [, int a ] ) bool dgsMenuSetItemColor ( element menu, int uniqueID, int color ) bool dgsMenuSetItemColor ( element menu, int uniqueID, table colors ) &lt;/syntaxhighlight&gt;  ===Required Arguments=== *'''menu:''' The DGS...&quot;</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=DgsMenuSetItemColor&amp;diff=82214&amp;oldid=prev"/>
		<updated>2025-07-10T06:18:20Z</updated>

		<summary type="html">&lt;p&gt;Created page with &amp;quot;{{Client function}} __NOTOC__ This function sets the color of a specific menu item. You can set both the normal and hover colors for the item.  ==Syntax== &amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt; bool dgsMenuSetItemColor ( element menu, int uniqueID, int r, int g, int b [, int a ] ) bool dgsMenuSetItemColor ( element menu, int uniqueID, int color ) bool dgsMenuSetItemColor ( element menu, int uniqueID, table colors ) &amp;lt;/syntaxhighlight&amp;gt;  ===Required Arguments=== *&amp;#039;&amp;#039;&amp;#039;menu:&amp;#039;&amp;#039;&amp;#039; The DGS...&amp;quot;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function sets the color of a specific menu item. You can set both the normal and hover colors for the item.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool dgsMenuSetItemColor ( element menu, int uniqueID, int r, int g, int b [, int a ] )&lt;br /&gt;
bool dgsMenuSetItemColor ( element menu, int uniqueID, int color )&lt;br /&gt;
bool dgsMenuSetItemColor ( element menu, int uniqueID, table colors )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
*'''menu:''' The DGS menu element containing the item&lt;br /&gt;
*'''uniqueID:''' The unique ID of the menu item (returned by [[dgsMenuAddItem]])&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
*'''r:''' The red component (0-255)&lt;br /&gt;
*'''g:''' The green component (0-255)&lt;br /&gt;
*'''b:''' The blue component (0-255)&lt;br /&gt;
*'''a:''' The alpha component (0-255). If not specified, 255 is used&lt;br /&gt;
*'''color:''' A single color value (created with [[tocolor]])&lt;br /&gt;
*'''colors:''' A table containing two color values: {normalColor, hoverColor}. If only one color is provided, it will be used for both states&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the color was set successfully, ''false'' otherwise.&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
===Example 1: Using RGB Values===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
loadstring(exports.dgs:dgsImportFunction())()-- load functions&lt;br /&gt;
&lt;br /&gt;
-- Create a menu with items&lt;br /&gt;
local menu = dgsCreateMenu(200, 200, 200, 150, false)&lt;br /&gt;
local item1 = dgsMenuAddItem(menu, &amp;quot;Red Item&amp;quot;, &amp;quot;red&amp;quot;)&lt;br /&gt;
local item2 = dgsMenuAddItem(menu, &amp;quot;Blue Item&amp;quot;, &amp;quot;blue&amp;quot;)&lt;br /&gt;
local item3 = dgsMenuAddItem(menu, &amp;quot;Green Item&amp;quot;, &amp;quot;green&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Set different colors for each item using RGB values&lt;br /&gt;
dgsMenuSetItemColor(menu, item1, 255, 0, 0)        -- Red&lt;br /&gt;
dgsMenuSetItemColor(menu, item2, 0, 0, 255, 200)   -- Blue with alpha&lt;br /&gt;
dgsMenuSetItemColor(menu, item3, 0, 255, 0)        -- Green&lt;br /&gt;
&lt;br /&gt;
-- Show the menu&lt;br /&gt;
dgsMenuShow(menu)&lt;br /&gt;
&lt;br /&gt;
-- Handle menu selections&lt;br /&gt;
addEventHandler(&amp;quot;onDgsMenuSelect&amp;quot;, menu, function(subMenu, uniqueID)&lt;br /&gt;
    if uniqueID == -1 then return end&lt;br /&gt;
    &lt;br /&gt;
    local command = dgsMenuGetItemCommand(source, uniqueID)&lt;br /&gt;
    outputChatBox(&amp;quot;Selected: &amp;quot; .. command)&lt;br /&gt;
    dgsMenuHide(source)&lt;br /&gt;
end, false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 2: Using Color Values===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
loadstring(exports.dgs:dgsImportFunction())()-- load functions&lt;br /&gt;
&lt;br /&gt;
-- Create a menu with items&lt;br /&gt;
local menu = dgsCreateMenu(200, 200, 200, 150, false)&lt;br /&gt;
local item1 = dgsMenuAddItem(menu, &amp;quot;Yellow Item&amp;quot;, &amp;quot;yellow&amp;quot;)&lt;br /&gt;
local item2 = dgsMenuAddItem(menu, &amp;quot;Purple Item&amp;quot;, &amp;quot;purple&amp;quot;)&lt;br /&gt;
local item3 = dgsMenuAddItem(menu, &amp;quot;Orange Item&amp;quot;, &amp;quot;orange&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Set colors using tocolor function&lt;br /&gt;
dgsMenuSetItemColor(menu, item1, tocolor(255, 255, 0))     -- Yellow&lt;br /&gt;
dgsMenuSetItemColor(menu, item2, tocolor(128, 0, 128))     -- Purple&lt;br /&gt;
dgsMenuSetItemColor(menu, item3, tocolor(255, 165, 0))     -- Orange&lt;br /&gt;
&lt;br /&gt;
-- Show the menu&lt;br /&gt;
dgsMenuShow(menu)&lt;br /&gt;
&lt;br /&gt;
-- Handle menu selections&lt;br /&gt;
addEventHandler(&amp;quot;onDgsMenuSelect&amp;quot;, menu, function(subMenu, uniqueID)&lt;br /&gt;
    if uniqueID == -1 then return end&lt;br /&gt;
    &lt;br /&gt;
    local command = dgsMenuGetItemCommand(source, uniqueID)&lt;br /&gt;
    outputChatBox(&amp;quot;Selected: &amp;quot; .. command)&lt;br /&gt;
    dgsMenuHide(source)&lt;br /&gt;
end, false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Example 3: Using Color Tables (Normal and Hover States)===&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
loadstring(exports.dgs:dgsImportFunction())()-- load functions&lt;br /&gt;
&lt;br /&gt;
-- Create a menu with items&lt;br /&gt;
local menu = dgsCreateMenu(200, 200, 200, 150, false)&lt;br /&gt;
local item1 = dgsMenuAddItem(menu, &amp;quot;Custom Colors&amp;quot;, &amp;quot;custom&amp;quot;)&lt;br /&gt;
local item2 = dgsMenuAddItem(menu, &amp;quot;Another Item&amp;quot;, &amp;quot;another&amp;quot;)&lt;br /&gt;
&lt;br /&gt;
-- Set different colors for normal and hover states&lt;br /&gt;
local normalColor = tocolor(100, 100, 100)    -- Gray when normal&lt;br /&gt;
local hoverColor = tocolor(255, 255, 255)     -- White when hovering&lt;br /&gt;
dgsMenuSetItemColor(menu, item1, {normalColor, hoverColor})&lt;br /&gt;
&lt;br /&gt;
-- You can also use the same color for both states&lt;br /&gt;
local singleColor = tocolor(255, 100, 100)    -- Light red&lt;br /&gt;
dgsMenuSetItemColor(menu, item2, {singleColor})  -- Will use the same color for both states&lt;br /&gt;
&lt;br /&gt;
-- Show the menu&lt;br /&gt;
dgsMenuShow(menu)&lt;br /&gt;
&lt;br /&gt;
-- Handle menu selections&lt;br /&gt;
addEventHandler(&amp;quot;onDgsMenuSelect&amp;quot;, menu, function(subMenu, uniqueID)&lt;br /&gt;
    if uniqueID == -1 then return end&lt;br /&gt;
    &lt;br /&gt;
    local command = dgsMenuGetItemCommand(source, uniqueID)&lt;br /&gt;
    outputChatBox(&amp;quot;Selected: &amp;quot; .. command)&lt;br /&gt;
    dgsMenuHide(source)&lt;br /&gt;
end, false)&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
*[[dgsMenuGetItemColor]]&lt;br /&gt;
*[[dgsMenuAddItem]]&lt;br /&gt;
*[[dgsMenuSetItemText]]&lt;br /&gt;
*[[dgsMenuSetItemTextSize]]&lt;br /&gt;
*[[dgsCreateMenu]]&lt;br /&gt;
&lt;br /&gt;
==Author==&lt;br /&gt;
[[User:Mohab|Mohab]].&lt;/div&gt;</summary>
		<author><name>Mohab</name></author>
	</entry>
</feed>