<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hussain+Mordhi</id>
	<title>Multi Theft Auto: Wiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Hussain+Mordhi"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Hussain_Mordhi"/>
	<updated>2026-05-22T04:20:22Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=RGBToHex&amp;diff=29653</id>
		<title>RGBToHex</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=RGBToHex&amp;diff=29653"/>
		<updated>2012-03-18T13:36:15Z</updated>

		<summary type="html">&lt;p&gt;Hussain Mordhi: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle&amp;gt;&amp;lt;/lowercasetitle&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function retrieves the hex string of a specified color.&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
string RGBToHex ( int red, int green, int blue [, int alpha = 255] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
* '''red:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space red] in the color (0-255).&lt;br /&gt;
* '''green:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space green] in the color (0-255).&lt;br /&gt;
* '''blue:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space blue] in the color (0-255).&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''alpha:''' The amount of [http://en.wikipedia.org/wiki/RGBA_color_space alpha] in the color (0-255).&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns a string representing the color in hexadecimal.&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Function source&amp;quot; class=&amp;quot;both&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function RGBToHex(red, green, blue, alpha)&lt;br /&gt;
	if((red &amp;lt; 0 or red &amp;gt; 255 or green &amp;lt; 0 or green &amp;gt; 255 or blue &amp;lt; 0 or blue &amp;gt; 255) or (alpha and (alpha &amp;lt; 0 or alpha &amp;gt; 255))) then&lt;br /&gt;
		return nil&lt;br /&gt;
	end&lt;br /&gt;
	if(alpha) then&lt;br /&gt;
		return string.format(&amp;quot;#%.2X%.2X%.2X%.2X&amp;quot;, red,green,blue,alpha)&lt;br /&gt;
	else&lt;br /&gt;
		return string.format(&amp;quot;#%.2X%.2X%.2X&amp;quot;, red,green,blue)&lt;br /&gt;
	end&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
This example will output the team color in the chat with HEX format&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function myTeamColor(Player,Command) -- adding the function&lt;br /&gt;
playerTeam = getPlayerTeam(Player)&lt;br /&gt;
   if playerTeam then&lt;br /&gt;
      r,g,b = getTeamColor(playerTeam)&lt;br /&gt;
          if r and g and b then&lt;br /&gt;
             outputChatBox(&amp;quot;your team color is : &amp;quot;..RGBToHex(r,g,b))&lt;br /&gt;
          end&lt;br /&gt;
   end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler(&amp;quot;myteamcolor&amp;quot;,myTeamColor) -- adding command handler&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Author: NeonBlack&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>Hussain Mordhi</name></author>
	</entry>
</feed>