Screen Module โ
The Screen module provides utility functions for controlling screen fade effects in RedM.
Getting Started โ
lua
local Screen = exports.bln_lib:screen()Methods โ
screen.fadeIn โ
Fade the screen in from black.
lua
Screen.screen.fadeIn(duration, needWait)Parameters
duration(number, optional): Fade duration in milliseconds (default: 500)needWait(boolean, optional): Wait for fade to complete before continuing
Example
lua
-- Simple fade in
Screen.screen.fadeIn()
-- Custom duration
Screen.screen.fadeIn(1000)
-- Wait for completion
Screen.screen.fadeIn(1000, true)screen.fadeOut โ
Fade the screen out to black.
lua
Screen.screen.fadeOut(duration, needWait)Parameters
duration(number, optional): Fade duration in milliseconds (default: 500)needWait(boolean, optional): Wait for fade to complete before continuing (default: true)
Example
lua
-- Simple fade out
Screen.screen.fadeOut()
-- Custom duration
Screen.screen.fadeOut(1000)
-- Don't wait for completion
Screen.screen.fadeOut(1000, false)Common Use Cases โ
Scene Transitions โ
lua
-- Teleport player with fade effect
function TeleportPlayer(coords)
    -- Fade out
    Screen.screen.fadeOut(1000)
    
    -- Teleport
    SetEntityCoords(PlayerPedId(), coords)
    
    -- Fade back in
    Screen.screen.fadeIn(1000)
endCutscene Control โ
lua
-- Start cutscene with fade
function StartCustomCutscene()
    -- Fade out
    Screen.screen.fadeOut()
    
    -- Setup cutscene
    PrepareCustomCutscene()
    
    -- Start cutscene and fade in
    StartCustomCutscene()
    Screen.screen.fadeIn(2000)
endLoading Screens โ
lua
-- Show loading screen
function ShowLoadingScreen()
    -- Fade out to black
    Screen.screen.fadeOut(500, true)
    
    -- Show loading text/spinner
    ShowLoadingPrompt()
    
    -- Do loading tasks
    LoadResources()
    
    -- Hide loading and fade in
    HideLoadingPrompt()
    Screen.screen.fadeIn(1000)
endInterior/Exterior Transitions โ
lua
-- Enter building
function EnterBuilding(interior)
    -- Fade out
    Screen.screen.fadeOut(1000, true)
    
    -- Load interior and teleport
    LoadInterior(interior.id)
    SetEntityCoords(PlayerPedId(), interior.coords)
    
    -- Fade in
    Screen.screen.fadeIn(1000)
endBest Practices โ
- Use Appropriate Durations
 
lua
-- Quick transitions
Screen.screen.fadeOut(500)  -- Half second
-- Dramatic effect
Screen.screen.fadeOut(2000) -- Two seconds- Wait When Needed
 
lua
-- Wait when doing post-fade actions
Screen.screen.fadeOut(1000, true)
DoSomething() -- This will run after fade completes
-- Don't wait when fade timing isn't critical
Screen.screen.fadeOut(1000, false)
DoSomething() -- This will run immediately- Error Handling
 
lua
function SafeFadeAndTeleport(coords)
    if not coords then return end
    
    Screen.screen.fadeOut(1000, true)
    
    -- Ensure coordinates are valid
    if type(coords) == "vector3" then
        SetEntityCoords(PlayerPedId(), coords)
        Screen.screen.fadeIn(1000)
    else
        -- Fade back in if something went wrong
        Screen.screen.fadeIn(500)
    end
end- Resource Management
 
lua
-- Clean up any ongoing effects when resource stops
AddEventHandler('onResourceStop', function(resourceName)
    if GetCurrentResourceName() ~= resourceName then return end
    
    -- Ensure screen is faded in when resource stops
    Screen.screen.fadeIn(0)
end)Performance Considerations โ
- Long fade durations with 
needWaitcreate a blocking operation - Use shorter durations for frequent transitions
 - Consider using 
needWait = falsefor non-critical fade effects 
Common Issues and Solutions โ
- Black Screen Stuck
 
lua
-- Force screen to fade in
Screen.screen.fadeIn(0)- Fade Timing Issues
 
lua
-- Ensure proper sequencing
async function SafeTransition()
    await Screen.screen.fadeOut(1000, true)
    -- Safe to perform transition
    await Screen.screen.fadeIn(1000, true)
end