JoinTransition - A simple transition between the loading screen and spawning the player


#1

JoinTransition

A simple script that adds a transition between the loading screen and spawning in-game. Should work with most custom loading screens, as well as the stock FiveM loading screen.

Demo

In case that embedded preview doesn’t work, try this: https://streamable.com/kcsk4

Download / Source :cloud:

Installation

  1. Download the latest release.
  2. Put the folder into your resources folder. (make sure that you end up with the __resource.lua being in the following location: resources/jointransition/__resource.lua)
  3. Add start jointransition to your server.cfg file.
  4. Start the server, enjoy.

Issues

  • There might be a few issues, because joining servers can sometimes be glitchy, this is usually caused by some buggy resource.
  • If you spot an issue in this resource itself, or have found a way to improve this, feel free to create a pull request. Or, if you just found the issue but don’t know how to solve it yourself, create an Issue on the GitHub page and make sure to provide as much information as possible.

Thanks to @Jaymo for helping me with the switch in native.


Flying Cam [GTA: Online Camera in Clouds]
GTA:Online teleport animation
#2

Great work on that man! I have to give it a try with my loading screen


#3

As long as your loading screen doesn’t manually call the ShutDownNui… native or whatever it’s called, then you should be fine.


#4

Aweosme like always!
+1


#5

Awsome great job +1 !!!


#6

good job as always man <3


#7

Very nice release. I was waiting for something like this :smiley:


#8

:ok_hand:


#9

Which loading screen is used in your preview? Sorry for the off-topic.


#10

keks it’s a default resource (in the [test] folder I believe)


#11

JoinTransition v1.1

Changes
Performance and overall stability improvements, now using less ‘estimated’ delays and instead actually waiting for switch states to change. This is possible after digging deep into the different switch states and doing a LOT of testing and frame-by-frame comparing of screen recordings of testing sessions.

Download
Latest release


#12

how can i hide the food hud esx_voice and the streetlabel ?


#13

Edit those resources to support proper hud hiding.


#14

i want to hide this

image
image

i have found this but i don’t know were i have to put it

DisplayRadar(false)
ESX.UI.HUD.SetDisplay(0.0)
TriggerEvent(‘es:setMoneyDisplay’, 0.0)
TriggerEvent(‘esx_status:setDisplay’, 0.0)

-- Copyright © Vespura 2018
-- Edit it if you want, but don't re-release this without my permission, and never claim it to be yours!


------- Configurable options  -------

-- set the opacity of the clouds
local cloudOpacity = 0.01 -- (default: 0.01)

-- setting this to false will NOT mute the sound as soon as the game loads 
-- (you will hear background noises while on the loading screen, so not recommended)
local muteSound = true -- (default: true)



------- Code -------

-- Mutes or un-mutes the game's sound using a short fade in/out transition.
function ToggleSound(state)
    if state then
        StartAudioScene("MP_LEADERBOARD_SCENE");
    else
        StopAudioScene("MP_LEADERBOARD_SCENE");
    end
end

-- Runs the initial setup whenever the script is loaded.
function InitialSetup()
    -- Stopping the loading screen from automatically being dismissed.
    SetManualShutdownLoadingScreenNui(true)
    -- Disable sound (if configured)
    ToggleSound(muteSound)
    -- Switch out the player if it isn't already in a switch state.
    if not IsPlayerSwitchInProgress() then
        SwitchOutPlayer(PlayerPedId(), 0, 1)
    end
end


-- Hide radar & HUD, set cloud opacity, and use a hacky way of removing third party resource HUD elements.
function ClearScreen()
    SetCloudHatOpacity(cloudOpacity)
    HideHudAndRadarThisFrame()
    
    -- nice hack to 'hide' HUD elements from other resources/scripts. kinda buggy though.
    SetDrawOrigin(0.0, 0.0, 0.0, 0)
end

-- Sometimes this gets called too early, but sometimes it's perfectly timed,
-- we need this to be as early as possible, without it being TOO early, it's a gamble!
InitialSetup()


Citizen.CreateThread(function()

    -- In case it was called too early before, call it again just in case.
    InitialSetup()
    
    -- Wait for the switch cam to be in the sky in the 'waiting' state (5).
    while GetPlayerSwitchState() ~= 5 do
        Citizen.Wait(0)
        ClearScreen()
    end
    
    -- Shut down the game's loading screen (this is NOT the NUI loading screen).
    ShutdownLoadingScreen()
    
    ClearScreen()
    Citizen.Wait(0)
    DoScreenFadeOut(0)
    
    -- Shut down the NUI loading screen.
    ShutdownLoadingScreenNui()
    
    ClearScreen()
    Citizen.Wait(0)
    ClearScreen()
    DoScreenFadeIn(500)
    while not IsScreenFadedIn() do
        Citizen.Wait(0)
        ClearScreen()
    end
    
    local timer = GetGameTimer()
    
    -- Re-enable the sound in case it was muted.
    ToggleSound(false)
    
    while true do
        ClearScreen()
        Citizen.Wait(0)
        
        -- wait 5 seconds before starting the switch to the player
        if GetGameTimer() - timer > 5000 then
            
            -- Switch to the player.
            SwitchInPlayer(PlayerPedId())
            
            ClearScreen()
            
            -- Wait for the player switch to be completed (state 12).
            while GetPlayerSwitchState() ~= 12 do
                Citizen.Wait(0)
                ClearScreen()
            end
            -- Stop the infinite loop.
            break
        end
    end
    
    -- Reset the draw origin, just in case (allowing HUD elements to re-appear correctly)
    ClearDrawOrigin()
end)


#15

Easiest thing would just be to make sure your other scripts don’t draw when IsPlayerSwitchActive() returns true. I won’t be adding an event for every single third party resource out there so that they can hide their HUD’s. They should’ve made it hidden when DisplayHud(false) is used and/or when IsPlayerSwitchActive() is true, which is extremely easy to do but they didn’t feel like making it compatible with other resources, so neither do I.


#16

i have to put

If IsPlayerSwitchActive then

           -- the thing i have to hide
end

where the script i showing the information
??


#17

Use if not IsPlayerSwitchActive() then wherever you draw something.


#18

ok thank you i will test that


#19

this is not showing up anymore
there is the code

Citizen.CreateThread(function()
	while true do
		Wait(1)
		
		if bringontherainbows then
			rgb = RGBRainbow(1)
		end
		
	if not IsPlayerSwitchActive() then
		
		SetTextColour(rgb.r, rgb.g, rgb.b, alpha)

		SetTextFont(font)
		SetTextScale(scale, scale)
		SetTextWrap(0.0, 1.0)
		SetTextCentre(false)
		SetTextDropshadow(2, 2, 0, 0, 0)
		SetTextEdge(1, 0, 0, 0, 205)
		SetTextEntry("STRING")
		AddTextComponentString(servername)
		DrawText(offset.x, offset.y)
		
		end
	end
end)