Suggesting a wait command for server config files (e.g.
server.cfg). Sometimes loading large amounts assets or scripts at once (e.g. server start) can cause computer lag.
fx_wait "5000" # 5s
fx_wait "20000" 20s cooldown for joining users
- Mitigate some compute lag.
- Cool down time for lower end systems.
- Prevent players from joining whilst
wait is active. This could give time for the platform server to cool down and the specs get a breather. Once it’s over, players can resume joining.
Cons & Notes
- Yes, the server owner could host better specifications.
- Yes, the server owner could just not use large assets or scripts.
May not get used as often, but maybe after trial & error there could be better benefits.
I’d like to hear some opinions on this suggestion. Maybe better alternatives for the server owner? Best type of smoked cheese? Send it over. Also, to be clear, I’ve just recently joined the FiveM community after losing interest in R*MP, so this might already exist (which I could not find in dev docs).
Hey @KC-1508 , welcome to FiveM community !
there are already scripts like Connect Queue that have a function like what you want, so you can have a delay and it just hold the players in a queue until the delay time is over
guess this should work for you nicely.
‘wait’ was more suggested to mitigate lag, but thanks for sharing that.
Some time ago I managed a server for someone who desperately wanted a lot of maps and addon cars. The server was weak and couldn’t start up in time, so a wait would be nice to have for the resource starts.
Anyways, I figured you or someone else finding this topic might still be interested in a solution, so I just wrote this resource that handles resource starts with wait timers. Basically your code example from above is how it works:
start another_resource # comments available
It also prevents users from joining while the server is still starting up.
It’s available on Github
… I’m confused how people didn’t realize that the command buffer (as also used for the ‘exec’ handler) already supports a ‘wait’ command, and I believe the server also already prevents joining until the initial command buffer is executed (and if not, that’d be a trivial thing to add).
Also, instead of suggesting this to ‘mitigate lag’ or fix other issues, reproduction cases for those issues would be a lot more helpful… same as the user above with ‘couldn’t start up in time’, what does ‘in time’ refer to here? In time for what?
Similarly, scanning resources’ stream/ files should only ever happen on first startup as it’s all cached in the ‘.sfl’ files so that not working would also be an issue of its own to report instead of making weird workarounds.
I think that’s just due to not being documented, or at least me (and likely others’) inability to find the documentation via Google/Official FiveM docs. And for someone who doesn’t know C++ at all, all I can guess is that there might be a specific wait command, or I’m completely misinterpreting those lines.
It does, so it doesn’t need to be added.
The person whom I managed a server for a short while wanted to have multiple car-packs (VanillaWorks as an example, getting up to a total of around 400 vehicles I believe) in addition to the Liberty City map mod which co-exists with the default map, which takes a while to fully load upon server start. When starting the server (dedicated Linux server from zap, later Windows VPS from OVH, around November 2021, server version 5020) it was in the middle of starting all the resources listed in the server config file and after about a minute or so (don’t know the exact time anymore) it would attempt to start again. I think the message mentioned not being able to start in time, potentially due to crashing on startup.
Later I tried running the server on my private PC (windows build, 5800X, 32GB RAM at 3200 MHz) and I expected it to successfully boot, however it still gave me the same message, although I did get further with it running on my PC.
This also works perfectly fine. When starting the server with all resources disabled, then starting them one-by-one or in smaller batches, the cache was created successfully and after that the resources did start up much faster, however it still wasn’t fast enough upon full server restarts.
I would have made posts about the issue, however it seemed like a very niche problem at the time so I decided not to bother anyone with yet another forum post titled “Server doesn’t do x when doing y” with a single answer saying “Don’t do y”, there’s already enough of those around.
Totally forgot about this post.
I’ll give that command a try sometime in the future!
For the future- there is no such thing as user error - even something that feels like it could be user error is likely just misunderstanding some context - and anything that feels odd should at least be asked about.