I just wrote this quick script because I thought having uptime shown on the fivem server list is very useful.
There’s no download because I didn’t justify someone downloading a file for the tiny code. Here’s how to very easily implement it to your server, simply read the installation manual and you should be good to go!
- Add the following to your server configuration file:
add_ace resource.uptime command.sets allow
In this case the resource has been named
uptime(if you fail to do this you’ll get an error that the
setscommand was denied)
- Add the below to a server sided FXserver file (must have the same resource name as above)
Citizen.CreateThread(function() local uptimeMinute, uptimeHour = 0, 0 while true do Citizen.Wait(1000 * 60) -- every minute uptimeMinute = uptimeMinute + 1 if uptimeMinute == 60 then uptimeMinute = 0 uptimeHour = uptimeHour + 1 end ExecuteCommand(string.format("sets Uptime \"%02dh %02dm\"", uptimeHour, uptimeMinute)) end end)