[HELP] DoScreenFadeOut / DoScreenFadeIn

Hi Guys!
I need some help with a script, i’m using some teleporters and i need some screen fade out’s and in’s.
As you can understand my screen isn’t fading in or out… See my code below.

function() -- Done
                                    ClearPedTasksImmediately(GetPlayerPed(-1))
                                    playerPed = PlayerPedId()
                                    gebruikt = false
                                    geteleporteerd = false
                                    DoScreenFadeOut(1000)
                                    ESX.Game.Teleport(playerPed, Cyclus.ContainerTeleport.Pos)
                                    DoScreenFadeIn(1000)
                                    Citizen.CreateThread(function () 
                                     countercontainer = Cyclus.container_timer
                                        while countercontainer > 0 do 
                                            exports['cyclus-notify']:notification(_U('overval_timer', countercontainer), 'error', '700')
                                            countercontainer = countercontainer -1
                                            Citizen.Wait(1000)
                                       end
                                       if geteleporteerd == false then
                                        DoScreenFadeOut(1000)
                                            ESX.Game.Teleport(playerPed, teleportpersoon)
                                        DoScreenFadeIn(1000)
                                       end
                                    end)

Do you guys know what i’m doing wrong?

Thanks in advance!

Try adding a Wait for the same time for both fade out and fade in’s, just after them.

Ie:

DoScreenFadeOut(1000)
Citizen.Wait(1000)
2 Likes

Absolute legend! It works, thanks!

You can also use IsScreenFadedIn - FiveM Natives @ Cfx.re Docs and IsScreenFadedOut - FiveM Natives @ Cfx.re Docs in loops, after setting the fade in/out, for a more accurate approach.

Setting the wait, while an overall ok approach, might not give the best result on low-end PCs.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.