<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.multitheftauto.com/wiki/GuiFadeElement?action=history&amp;feed=atom</id>
	<title>GuiFadeElement - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.multitheftauto.com/wiki/GuiFadeElement?action=history&amp;feed=atom"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiFadeElement&amp;action=history"/>
	<updated>2026-05-06T12:06:58Z</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=GuiFadeElement&amp;diff=55325&amp;oldid=prev</id>
		<title>KillerProject: This function fades -decrease/increase- gui elements</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=GuiFadeElement&amp;diff=55325&amp;oldid=prev"/>
		<updated>2018-06-15T15:54:11Z</updated>

		<summary type="html">&lt;p&gt;This function fades -decrease/increase- gui elements&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;{{Useful Function}}&lt;br /&gt;
&amp;lt;lowercasetitle/&amp;gt;&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function fades -decrease/increase- gui elements&lt;br /&gt;
&lt;br /&gt;
==Syntax==&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
guiFadeElement ( element guiElement, bool state[, int speed, int decrease/increase] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''guiElement''': the GUI element.&lt;br /&gt;
* '''state''': the new visibility state (true/false).&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
{{OptionalArg}}&lt;br /&gt;
* '''speed''': speed to decrease or increase the guiElement's alpha (from 50 to unlimited).&lt;br /&gt;
* '''decrease/increase''': decrease/increase's amount (from 1 to 255).&lt;br /&gt;
&lt;br /&gt;
==Code==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&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 guiFadeElement ( element, boolean, time, inOut )&lt;br /&gt;
	if isElement ( element ) ~= true or type ( boolean ) ~= &amp;quot;boolean&amp;quot; then return false end&lt;br /&gt;
	guiSetEnabled ( element, boolean )&lt;br /&gt;
	if type ( fadeTable ) ~= &amp;quot;table&amp;quot; then fadeTable = {} end&lt;br /&gt;
	if getElementData ( element, &amp;quot;real.alpha&amp;quot; ) == false then setElementData ( element, &amp;quot;real.alpha&amp;quot;, ( ( guiGetAlpha ( element ) / 1 ) * 255 ) ) end&lt;br /&gt;
	if guiGetVisible ( element ) == false then guiSetAlpha ( element, 0 ) end&lt;br /&gt;
	local remove = function ( element ) if isTimer ( getElementData ( element, &amp;quot;gui.timer&amp;quot; ) ) then killTimer ( getElementData ( element, &amp;quot;gui.timer&amp;quot; ) ) end end&lt;br /&gt;
	remove ( element )&lt;br /&gt;
	local execute = function ( element, boolean, inOut )&lt;br /&gt;
		if boolean == false then&lt;br /&gt;
			guiSetAlpha ( element, ( ( ( guiGetAlpha ( element ) / 1 ) * 255 ) - ( inOut or 25 ) ) / 255 )&lt;br /&gt;
			if ( ( guiGetAlpha ( element ) / 1 ) * 255 ) &amp;lt;= 5 then&lt;br /&gt;
				remove ( element )&lt;br /&gt;
				guiSetAlpha ( element, 0 )&lt;br /&gt;
				guiSetVisible ( element, boolean )&lt;br /&gt;
			end&lt;br /&gt;
		elseif boolean == true then&lt;br /&gt;
			guiSetVisible ( element, boolean )&lt;br /&gt;
			guiSetAlpha ( element, ( ( ( guiGetAlpha ( element ) / 1 ) * 255 ) + ( inOut or 25 ) ) / 255 )&lt;br /&gt;
			if ( ( guiGetAlpha ( element ) / 1 ) * 255 ) &amp;gt;= tonumber ( getElementData ( element, &amp;quot;real.alpha&amp;quot; ) ) then&lt;br /&gt;
				remove ( element )&lt;br /&gt;
				guiSetAlpha ( element, getElementData ( element, &amp;quot;real.alpha&amp;quot; ) / 255 )&lt;br /&gt;
			end&lt;br /&gt;
		end&lt;br /&gt;
	end&lt;br /&gt;
	guiTimer = setTimer ( execute, ( time or 50 ), 0, element, boolean, inOut )&lt;br /&gt;
	setElementData ( element, &amp;quot;gui.timer&amp;quot;, guiTimer )&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br /&amp;gt;'''Author:''' [https://forum.mtasa.com/profile/51427-killerProject killerProject]&amp;lt;br /&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Examples==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;section name=&amp;quot;Client&amp;quot; class=&amp;quot;client&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;
button = guiCreateButton(50, 50, 150, 50, &amp;quot;killerProject&amp;quot;, false)&lt;br /&gt;
&lt;br /&gt;
function test ()&lt;br /&gt;
	guiFadeElement ( button, not guiGetVisible ( b ) )&lt;br /&gt;
end&lt;br /&gt;
setTimer ( test, 1*1000, 0 )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Useful_Functions}}&lt;/div&gt;</summary>
		<author><name>KillerProject</name></author>
	</entry>
</feed>