Disable Connection while starting up

fivem
help
resources

#1

Hey guys, Curious if there is some alternative way to not display the server on the FiveM serverlist until all resources are fully loaded. The main issue with this is individuals on high populated servers rejoin instantly after restarts and they load in without all resources fully loaded on the server, Which as a result causes them to have issues and have to relog.

I thought of a way but have not yet attempted it but I’m sure there is something that we can do that I am just not aware of yet.

I was thinking of implementing a whitelist and state the kick message as (“Please wait for resources to load try again in a moment”) Then at the end of the resource list stop the whitelist resource so that once the server is fully loaded the whitelist will then be disabled and allow them to connect otherwise they would just be able to join before certain things are loaded. Just curious I have not looked to much into this it becomes a huge issue when you have a highly populated active server. People can’t be patient and wait so I have to come up with an alternative method.

So I’m just curious about how or if there is a way to implement this and if you have figured out how to disable people connecting or the server showing on the list until everything is loaded please inform me would be greatly appreciated.


#2

A variation on this theme:

Resource initkick:

local connectionEvent = AddEventHandler('playerConnecting', function(a, setReason)
    setReason('The server is still starting up, please wait and try again in a little while.')
    CancelEvent()
end)

RegisterCommand('initkick_done', function()
    SetTimeout(100, function() -- 100ms wait so that any resources that do something on tick can run
        if connectionEvent then
            RemoveEventHandler(connectionEvent)
            connectionEvent = nil
        end
    end)
end, true)

Server configuration file:

start initkick # do this before your endpoint adds so people can't accidentally connect before initkick runs

add_endpoint_tcp # blah

# the rest of your stuff
start esx_potato
start vrp_slow
start es_evenslower
start slowstuff

set randomstuff "blah"

# run the command from `initkick`
initkick_done

You could go all fancy and use deferrals as well but I’m not sure if that’ll work well if you have any other resource that handles playerConnecting too. :stuck_out_tongue:


#3

is this ready to be used or not?