<?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=Prophet061</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=Prophet061"/>
	<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/wiki/Special:Contributions/Prophet061"/>
	<updated>2026-05-25T20:11:17Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.39.3</generator>
	<entry>
		<id>https://wiki.multitheftauto.com/index.php?title=FadeCamera&amp;diff=62347</id>
		<title>FadeCamera</title>
		<link rel="alternate" type="text/html" href="https://wiki.multitheftauto.com/index.php?title=FadeCamera&amp;diff=62347"/>
		<updated>2019-03-13T19:47:21Z</updated>

		<summary type="html">&lt;p&gt;Prophet061: &amp;quot;Any number less than 1 makes the fade instant.&amp;quot; isn't true. Values smaller than 1 work normally.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{Server client function}}&lt;br /&gt;
__NOTOC__&lt;br /&gt;
This function will fade a player's camera to a color or back to normal over a specified time period. This will also affect the sound volume for the player (50% faded = 50% volume, full fade = no sound). For clientside scripts you can perform 2 fade ins or fade outs in a row, but for serverside scripts you must use one then the other.&lt;br /&gt;
&lt;br /&gt;
{{Note|The speed of the effect depends directly on the current gamespeed.}}&lt;br /&gt;
&lt;br /&gt;
==Syntax==&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;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||[[player]]:fadeCamera}}&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''thePlayer:''' The player whose camera you wish to fade.&lt;br /&gt;
* '''fadeIn:''' Should the camera be faded in or out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''timeToFade:''' The number of seconds it should take to fade.&lt;br /&gt;
* '''red:''' The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
* '''green:''' The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
* '''blue:''' The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
&amp;lt;/section&amp;gt;&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;
bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;br /&gt;
{{OOP||Camera.fade}}&lt;br /&gt;
===Required Arguments===&lt;br /&gt;
* '''fadeIn:''' Should the camera be faded in our out? Pass ''true'' to fade the camera in, ''false'' to fade it out to a color.&lt;br /&gt;
&lt;br /&gt;
===Optional Arguments===&lt;br /&gt;
* '''timeToFade:''' The number of seconds it should take to fade.&lt;br /&gt;
* '''red:''' The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
* '''green:''' The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
* '''blue:''' The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.&lt;br /&gt;
&amp;lt;/section&amp;gt;&lt;br /&gt;
&lt;br /&gt;
===Returns===&lt;br /&gt;
Returns ''true'' if the camera was faded successfully, ''false'' if invalid arguments were passed to the function.&lt;br /&gt;
&lt;br /&gt;
==Example==&lt;br /&gt;
&amp;lt;section name=&amp;quot;Server example&amp;quot; class=&amp;quot;server&amp;quot; show=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
When a player gets damaged, place a quick fade-to-red effect on his screen.&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
function addRednessOnDamage ( )&lt;br /&gt;
      fadeCamera ( source, false, 1.0, 255, 0, 0 )         -- fade the player's camera to red over a period of 1 second&lt;br /&gt;
      setTimer ( fadeCameraDelayed, 500, 1, source )   -- don't let it go to opaque red, interrupt it after half a second and fade back to normal&lt;br /&gt;
end&lt;br /&gt;
addEventHandler ( &amp;quot;onPlayerDamage&amp;quot;, root, addRednessOnDamage )&lt;br /&gt;
&lt;br /&gt;
function fadeCameraDelayed(player) -- This function prevents debug warnings when the player disconnects while the timer is running.&lt;br /&gt;
      if (isElement(player)) then&lt;br /&gt;
            fadeCamera(player, true, 0.5)&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;
&lt;br /&gt;
==See Also==&lt;br /&gt;
{{Camera_functions}}&lt;br /&gt;
&lt;br /&gt;
[[hu:fadeCamera]]&lt;/div&gt;</summary>
		<author><name>Prophet061</name></author>
	</entry>
</feed>