[LUA] Check if an area is fully loaded before fading in the screen?

I’ve been editing SimpleX’s Simpletp to be more like GTAO’s native teleporting by adding a fade to the screen and fading the player as well. Everything I’ve added works great except checking if an area is fully rendered in, I found a native that checks if an entity’s collision has loaded in but not if the area around has rendered (example for slower HDDs). When quickly teleporting from one area to another, the game will be unrendered for a good few seconds. GTAO loads the entire area before removing the fade screen so is it possible that we can do it too? Here is a snipper of what I have currently:

            if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc1.x, loc1.y, loc1.z, 2) then 
                alert(teleport_text)
                
                if IsControlJustReleased(1, key_to_teleport) then
				--PlaySoundFrontend(-1, "SELECT", "HUD_FREEMODE_SOUNDSET", 1)
				FreezeEntityPosition(player, true)
				DoScreenFadeOut(1000)
				
				while ( not IsScreenFadedOut() ) do
				Citizen.Wait(1)
				end
				
				NetworkFadeOutEntity(PlayerPedId(), true, false)
				
				while NetworkIsEntityFading(PlayerPedId()) do
				Citizen.Wait(1)
				end
				
				local cam = GetFollowPedCamViewMode()
				SetFollowPedCamViewMode(1)
                    if IsPedInAnyVehicle(player, true) then
                        SetEntityCoords(GetVehiclePedIsUsing(player), loc2.x, loc2.y, loc2.z)
                        SetEntityHeading(GetVehiclePedIsUsing(player), loc2.heading)
                    else
                        SetEntityCoords(player, loc2.x, loc2.y, loc2.z+0.2)
                        SetEntityHeading(player, loc2.heading)
					end
					
				while (not HasCollisionLoadedAroundEntity(PlayerPedId())) and ( not AreAllNavmeshRegionsLoaded() ) do -- HERE IS WHERE THE CHECK WILL GO TO SEE IF AN AREA HAS FULLY LOADED
					Citizen.Wait(1)
				end
				
				NetworkFadeInEntity(PlayerPedId(), 1, 0)
				while NetworkIsEntityFading(PlayerPedId()) do
				Citizen.Wait(1)
				end
				FreezeEntityPosition(player, false)
				DoScreenFadeIn(1000)
				while ( not IsScreenFadedIn() ) do
				Citizen.Wait(1)
				end
				SetFollowPedCamViewMode(cam)
                end
					

Try using START_PLAYER_TELEPORT and fade out the screen while IS_PLAYER_TELEPORT_ACTIVE

Amazing man, thank you.

           if CheckPos(playerLoc.x, playerLoc.y, playerLoc.z, loc1.x, loc1.y, loc1.z, 2) and IsPedOnFoot(PlayerPedId()) then 
                alert(teleport_text)
                
                if IsControlJustReleased(1, key_to_teleport) then
				--FreezeEntityPosition(player, true)
				
				local cam = GetFollowPedCamViewMode()
				SetFollowPedCamViewMode(1)
				DoScreenFadeOut(1000)
						while ( not IsScreenFadedOut() ) do
				Citizen.Wait(0)
				end		
				
				StartPlayerTeleport(PlayerId(), loc2.x, loc2.y, loc2.z, loc2.heading, true, true, true)
					
				while IsPlayerTeleportActive() do
				Citizen.Wait(0)
				end
				
				
				DoScreenFadeIn(1000)
				SetFollowPedCamViewMode(cam)
                end
end
1 Like