diff --git a/resources/[system]/spawnmanager/spawnmanager.lua b/resources/[system]/spawnmanager/spawnmanager.lua index b4cf87b..1aa46f1 100644 --- a/resources/[system]/spawnmanager/spawnmanager.lua +++ b/resources/[system]/spawnmanager/spawnmanager.lua @@ -208,12 +208,6 @@ function spawnPlayer(spawnIdx, cb) spawnLock = true Citizen.CreateThread(function() - DoScreenFadeOut(500) - - while IsScreenFadingOut() do - Citizen.Wait(0) - end - -- if the spawn isn't set, select a random one if not spawnIdx then spawnIdx = GetRandomIntInRange(1, #spawnPoints + 1) @@ -228,6 +222,14 @@ function spawnPlayer(spawnIdx, cb) spawn = spawnPoints[spawnIdx] end + if not spawn.skipFade then + DoScreenFadeOut(500) + + while not IsScreenFadedOut() do + Citizen.Wait(0) + end + end + -- validate the index if not spawn then Citizen.Trace("tried to spawn at an invalid spawn index\n") @@ -288,16 +290,20 @@ function spawnPlayer(spawnIdx, cb) --loadScene(spawn.x, spawn.y, spawn.z) --ForceLoadingScreen(false) - while not HasCollisionLoadedAroundEntity(ped) do + local time = GetGameTimer() + + while (not HasCollisionLoadedAroundEntity(ped) and (GetGameTimer() - time) < 5000) do Citizen.Wait(0) end ShutdownLoadingScreen() - DoScreenFadeIn(500) + if IsScreenFadedOut() then + DoScreenFadeIn(500) - while IsScreenFadingIn() do - Citizen.Wait(0) + while not IsScreenFadedIn() do + Citizen.Wait(0) + end end -- and unfreeze the player