<?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=Upstream</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=Upstream"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Upstream"/>
	<updated>2026-05-02T02:34:19Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=GetColorFromString&amp;diff=15066</id>
		<title>GetColorFromString</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GetColorFromString&amp;diff=15066"/>
		<updated>2008-01-17T18:22:40Z</updated>

		<summary type="html">&lt;p&gt;Upstream: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function will extract Red, Green, Blue and Alpha values from a hex string you provide it. These strings follow the same format as used in HTML, with addition of the Alpha values.&lt;br /&gt;
&lt;br /&gt;
==Syntax== &lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;int int int int getColorFromString ( string theColor )&amp;lt;/syntaxhighlight&amp;gt; &lt;br /&gt;
&lt;br /&gt;
===Required Arguments=== &lt;br /&gt;
*'''theColor:''' A string containing a valid color code.&lt;br /&gt;
&lt;br /&gt;
:Valid strings are:&lt;br /&gt;
:* '''#RRGGBB''': Colors specified, Alpha assumed to be 255.&lt;br /&gt;
:* '''#RRGGBBAA''': All values specified.&lt;br /&gt;
:* '''#RGB''': Shortened form, will be expanded internally to RRGGBB, as such it provides a smaller number of colors.&lt;br /&gt;
:* '''#RGBA''': As above, shortened - each character is duplicated.&lt;br /&gt;
&lt;br /&gt;
:For example:&lt;br /&gt;
:* '''#FF00FF''' is Red: 255, Green: 0, Blue: 255, Alpha: 255&lt;br /&gt;
:* '''#F0F''' is Red: 255, Green: 0, Blue: 255, Alpha: 255 (the same as the example above)&lt;br /&gt;
:* '''#34455699''' is Red: 52, Green: 69, Blue: 86, Alpha: 153&lt;br /&gt;
&lt;br /&gt;
All colors used must begin with a # sign.&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns four integers in RGBA format, with a maximum value of 255 for each.  Each stands for ''red'', ''green'', ''blue'', and ''alpha''.  Alpha decides transparancy where 255 is opaque and 0 is transparent.  ''false'' is returned if the string passed is invalid (for example, is missing the preceeding # sign).&lt;br /&gt;
&lt;br /&gt;
==Example== &lt;br /&gt;
This example will set the blip attached to a player to a color they specify by typing ''set_my_color [color]'' in the console.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function setPlayerBlipColor ( playerSource, commandName, colorString )&lt;br /&gt;
    local red, green, blue, alpha = getColorFromString ( colorString )  -- convert the color string to numbers&lt;br /&gt;
    local playerBlip = getBlipAttachedTo ( playerSource )               -- find the blip attached to the player&lt;br /&gt;
    if ( playerBlip and red ) then                                      -- check a blip is attached to the player and that a valid color was specified&lt;br /&gt;
        setBlipColor ( playerBlip, red, green, blue, alpha )            -- set the player's blip color&lt;br /&gt;
    end&lt;br /&gt;
end&lt;br /&gt;
addCommandHandler ( &amp;quot;set_my_color&amp;quot;, setPlayerBlipColor )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Utility_functions}}&lt;/div&gt;</summary>
		<author><name>Upstream</name></author>
	</entry>
</feed>