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
Installation
Download the latest release .
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
)
Add start jointransition
to your server.cfg file.
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.
54 Likes
Great work on that man! I have to give it a try with my loading screen
2 Likes
As long as your loading screen doesn’t manually call the ShutDownNui… native or whatever it’s called, then you should be fine.
2 Likes
IceHax
October 13, 2018, 6:16pm
6
good job as always man <3
1 Like
Very nice release. I was waiting for something like this
1 Like
Which loading screen is used in your preview? Sorry for the off-topic.
Vespura
October 14, 2018, 11:33pm
10
keks
it’s a default resource (in the [test] folder I believe)
2 Likes
Vespura
October 18, 2018, 8:18pm
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
2 Likes
how can i hide the food hud esx_voice and the streetlabel ?
2 Likes
Vespura
December 3, 2018, 12:41am
13
Edit those resources to support proper hud hiding.
i want to hide this
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)
Vespura
December 4, 2018, 12:54am
15
Myloulou_Minecraft:
i want to hide this
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)
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.
1 Like
i have to put
If IsPlayerSwitchActive then
-- the thing i have to hide
end
where the script i showing the information
??
Vespura
December 5, 2018, 4:38pm
17
Use if not IsPlayerSwitchActive() then
wherever you draw something.
ok thank you i will test that
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)
whenever i use SwitchInPlayer at server startup i keep falling from the textures… i tried with RequestCollisionAtCoord but still happening because i teleport the ped while switching… it happens only at first entrance… if i restart the resource while inside the server and rejoin it doesn’t happen