Help understanding spawnmanager

Hi ,
I’m trying to create a login system with the help of spawnmanager.
What I’m trying to do is serve a UI page in the onClientGameTypeStart event after disabling autospawn.

But when I connect to the server, it just says “Awaiting scripts” after loading. i.e its not serving the UI page. When I remove the below line the UI login page loads up but player is spawned automatically before logging in

exports.spawnmanager:setAutoSpawn(false)

Below is my full code for the event


AddEventHandler("onClientGameTypeStart", function(spawn)
   exports.spawnmanager:setAutoSpawn(false)
   TriggerServerEvent('loginMenu')
    end)

If I dont set the auto spawn to false, my login page works perfectly but the problem is that player is spawned even before logging in. I want the player to spawn only after logging in

try SHUTDOWN_LOADING_SCREEN: https://runtime.fivem.net/doc/natives/?_0x078EBE9809CCD637

ok this got me past the “Awaiting scripts”
but I’m spawning somewhere now. I can see the character in some location for a short time before the ui page loads and I can hear in game vehicle noise.

Would it work if I enable AutoSpawn and put

exports.spawnmanager:spawnPlayer

inside an if condition based on my login script?

correct; that’s how the game is supposed to work

you might be interested in a loading screen resource with ‘manual shutdown’ enabled so you can make an entirely custom transition

only enable autospawn by the time you want to spawn, or it’ll probably go respawn you

1 Like

I didn’t know we could do manual shutdown with loadscreen. This seems like a simple approach to what I was trying to do in a complicated way. I already had a loadscreen but I tried to load a new UI page after the loadscreen has ended.
Thank you , I’ll try this out

how do you do the manual shutdown i get that in my f8

This guide really helped me understand.
Just go through the code given in the GitHub link on the above linked thread and you’ll understand. It’s not that complex really

3 Likes