Santa & Christmas Edition36 maps, limited runlimited runShop the drop
Chapter 02 of 8The Loading Screens Handbook for FiveM

Connecting: deferrals, adaptive cards, queues, whitelists and join links

In short

Between the click and the loading screen, the server can hold a player, report progress, ask questions on a card, check a whitelist or put them in a queue. All of it runs through deferrals, and one short link gets the player to that point from anywhere.

server.lua
AddEventHandler('playerConnecting', function(name, setKickReason, deferrals)
    local src = source
    deferrals.defer()
    Wait(0)

    deferrals.update(('Checking your whitelist, %s…'):format(name))
    local license = GetPlayerIdentifierByType(src, 'license')
    if not license or not IsWhitelisted(license) then
        return deferrals.done('Not whitelisted — apply on discord.gg/example')
    end

    deferrals.handover({ name = name })
    deferrals.done()
end)
CallDoes
deferrals.defer()Hold the connection (then wait at least one tick)
deferrals.update(text)Show a progress message
deferrals.presentCard(card, cb)Show an Adaptive Card with inputs and buttons
deferrals.handover(data)Pass data to the loading screen
deferrals.done() / done(reason)Let them in, or refuse with a reason
  • Make every code path finish in deferrals.done. A path that does not leaves the player hanging on “connecting”.
  • A queue keeps players inside deferrals, orders them by priority and join time, and refreshes their position every few seconds.
  • A whitelist usually checks for a Discord role through the bot API and caches the answer briefly.
  • Build cards at adaptivecards.io and keep to simple 1.x elements.

The value passed to deferrals.handover is what the loading screen later reads from window.nuiHandoverData; the page side is in building the screen.

A single link that opens the client and connects is the most useful thing to put in every post, video and profile. It comes in three forms.

WhereUse
Anywherehttps://cfx.re/join/<code>
Website “Play” buttonfivem://connect/cfx.re/join/<code>
F8 consoleconnect cfx.re/join/<code> or connect ip:port

The code is the ID at the end of your page on servers.fivem.net. It is tied to your listing and key — keep the same key when you change hosts.

The Loading Screens Handbook for FiveM

This chapter is one of 8. The handbook also carries the manifest, message, server list and NUI cheat sheets, a glossary and the official references every chapter is checked against.

Open the handbook