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

this was never tested with custom spawn manager stuff. This resource waits for the player to be spawned before switching out and before shutting down the loading screen.

edit: it waits for the player to be spawned before switching back in, it doesn’t wait for the player to be spawned because that caused issues with the loading screen.

i see :slight_smile: Many thanks and good xMas

1 Like

i too also fall through the map 50% of the time because its like it dosent load…

Another great release from @Vespura. Added it to my server and haven’t received any complaints from it. Gives that nice SP GTA feel to it.

it is a really nice release just wish i could get this issue worked out.

so I think the issue with this situation of the map not loading… is because at least with me it loads my character in a different position then it spawns into a new spot with my skin and everything else as it loads so the screen is not focused on the character and the character is in a different spot by the time the screen comes down to the character it just got moved to the new location in my case its last logout postion… and textures don’t load fast enough… and I fall through i have not had a chance to test this code on anyone but myself it may need a longer wait before unfreezing the entity for some people but my pc loads fast enough for it to only need 1 sec after it brakes the loop I hope @vespura does not mind I’m going to post a snippet of the code here

 local ped = GetPlayerPed(-1)
    local player = PlayerId()

    SetPlayerInvincible(player, true)
    SetEntityCollision(ped, false)
    FreezeEntityPosition(ped, true)

    
    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()
    local ped = GetPlayerPed(-1)
    local player = PlayerId()
    Citizen.Wait(1000)
    SetPlayerInvincible(player, false)
    FreezeEntityPosition(ped, false)
    SetEntityVisible(ped, true)
    SetEntityCollision(ped, true)
	Citizen.Wait(2000)
	TriggerEvent('disclaimer:display', true)
end)

Ignore the TriggerEvent for the Disclaimer display that is a pop up i have for my server specifically but as you can see in the start it freezes the entity and make you invulnerable wich that part is not needed all you really need to do is freeze the entity so you don’t fall through the world. but i added extra in its a preference … anyways at the end of the code

  -- Reset the draw origin, just in case (allowing HUD elements to re-appear correctly)
    ClearDrawOrigin()
    local ped = GetPlayerPed(-1)
    local player = PlayerId()
    Citizen.Wait(1000)
    SetPlayerInvincible(player, false)
    FreezeEntityPosition(ped, false)
    SetEntityVisible(ped, true)
    SetEntityCollision(ped, true)
	Citizen.Wait(2000)
	TriggerEvent('disclaimer:display', true)
end)`

it ends it here after the fact with that 1 sec delay to release you. and at that point atleast for me the map is loaded i hope this explantion can help some people with custom spawn events this is very nice and simple release of a script yet again by vespura that just adds some nice falir to the start :smiley: thank you.

This is not something that’s ‘broken’ in this resource. instead, fix the script that teleports you to a new location after you’ve spawned. And make sure that requests collision, freezes the player until the collision is loaded, or heck even keep freezing the player while IsPlayerSwitchInProgress() is true. But this is not a bug of this resource so you shouldn’t edit this resource to fix a bug that’s caused by another resource.

again, not a bug of this resource, but rather a bug in your teleport script.

how do you know that 1 second will work in all cases? You can’t just assume a certain delay there.

Why the fuck would you disable collision if you’re “waiting” for a collision and you don’t want people to fall through the map… That’s the exact opposite of what you want to be doing.

because your being frozen so it dosent matter if you have collision but i also dont want players punching or people running you over or AI messing with you while your flying down from space. as i said everything but the freezing is not mandatory it just preference… i posted it to help anyone else with custom spawn systems i also did say that 1 sec may not work for anyone and that i only TESTED it on myself and my loadtime works for that. i did not say your script was broken its simply a work around. im unsure of the hostility’s but you can delete the post if you want. but its alot easier to edit it right in your script so when it ends it unfreezes rather than playing guessing games in my teleport script for when to end the freeze based of idk a wait? for how long it will take for someone to load in. and finish that process if it unfreezes to early they wont load the map and will fall through its all based on load times

Not hostile at all, just saying the ‘fix’ or ‘workaround’ shouldn’t be done in this resource. Why would I remove the post? That’s just stupid.

edit: if I was being hostile then i would’ve removed the post for sure, but i honestly am just saying that it’s pointless doing it in this resource because it doesn’t fix the bug in the resource that causes it.

Not sure normally you seem pretty reasonable was just surprised you picked apart something that would just be simple work around for some people. Its not for everyone but it would help people get on the right track like the guy above who dident know where to start. Like i said if i try and do the freezing on my side and not after all your script events have ended i have to guess timing and that could cause issues for the player like falling through the world again. its really just a safety net added to your script to keep you were you should be until its done doing what it needs to.

was it a confirm fix to stop falling through the map?

You should fix whatever resource makes you re-spawn incorrectly. Not a bug with this resource.

Humm interesting that I don’t spawn through the map before using this but spawn in the map when using this…but its another resource? Its not when I die and re-spawn it’s when player connects initially…I guess i could stop other resourced one at a time till i find it.

Most likely another resource is teleporting the player to a new location after the player has spawned (while the join transition is active). Because the camera is far away from the player, the world around the player may not load fast enough for the player to not fall through when another resource teleports the player after spawning.

Your resource that teleports the player after being spawned by spawnmanager should freeze the player until collisions around the entity are loaded.

So yes, it does make sense that you did not have this issue before using this resource, because the camera (rendered part of the world) was loaded around the player when teleporting.

Got ya I’ll check into

I am trying to add this into my sky camera for a character system im making but it is saying that the switch into player is a nil value and the same for switching into player. Before trying this I used render script cam to ease out of it but I want this. Any idea why it says it is nil?

Sounds like something doesn’t exist, but you’re not really providing any context or further information. Which isn’t really suited for this page anyway since it isn’t really about this script at all, you’re trying to make your own script and use the switch natives from what I can tell. Maybe try asking in #development:scripts for that and providing your code?

This is a really nice resource! I use it with a custom loading screen and have no issue.
Good job!

1 Like

Love the little vMenu resource warning

Sorry i know this is old, but this would be the same as “IsPlayerSwitchInProgress()” right?