fadeCamera
Client-side
Server-side
Shared
This function will fade a player's camera to a color or back to normal over a specified time period.
Note
- 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.
OOP Syntax Help! I don't understand this!
Server OOP syntax
- Method:player:fadeCamera(...)
Client OOP syntax
- Method:Camera.fade(...)
Client Syntax
bool fadeCamera ( bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )Required Arguments
- fadeIn: Should the camera be faded in or out? Pass true to fade the camera in, false to fade it out to a color.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- timeToFade (default: 1.0): The number of seconds it should take to fade.
- red (default: 0): The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.
- green (default: 0): The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.
- blue (default: 0): The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.
Returns
- bool: result
Returns true if the camera was faded successfully, false if invalid arguments were passed to the function.
Server Syntax
bool fadeCamera ( player thePlayer, bool fadeIn, [ float timeToFade = 1.0, int red = 0, int green = 0, int blue = 0 ] )Required Arguments
- thePlayer: The player whose camera you wish to fade.
- fadeIn: Should the camera be faded in or out? Pass true to fade the camera in, false to fade it out to a color.
Optional Arguments
NOTE: When using optional arguments, you might need to supply all arguments before the one you wish to use.
- timeToFade (default: 1.0): The number of seconds it should take to fade.
- red (default: 0): The amount of red in the color that the camera fades out to (0 - 255). Not required for fading in.
- green (default: 0): The amount of green in the color that the camera fades out to (0 - 255). Not required for fading in.
- blue (default: 0): The amount of blue in the color that the camera fades out to (0 - 255). Not required for fading in.
Returns
- bool: result
Returns true if the camera was faded successfully, false if invalid arguments were passed to the function.
Code Examples
server
When a player gets damaged, place a quick fade-to-red effect on his screen.
function addRednessOnDamage() fadeCamera(source, false, 1.0, 255, 0, 0) -- fade the player's camera to red over a period of 1 second setTimer(fadeCameraDelayed, 500, 1, source) -- don't let it go to opaque red, interrupt it after half a second and fade back to normalendaddEventHandler("onPlayerDamage", root, addRednessOnDamage)
function fadeCameraDelayed(player) -- This function prevents debug warnings when the player disconnects while the timer is running. if (isElement(player)) then fadeCamera(player, true, 0.5) endendSee Also
Camera Functions
- fadeCamera
- getCamera
- getCameraClip
- getCameraDrunkLevel
- getCameraFieldOfView
- getCameraGoggleEffect
- getCameraInterior
- getCameraMatrix
- getCameraTarget
- getCameraViewMode
- resetShakeCamera
- setCameraClip
- setCameraDrunkLevel
- setCameraFieldOfView
- setCameraGoggleEffect
- setCameraInterior
- setCameraMatrix
- setCameraTarget
- setCameraViewMode
- shakeCamera