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(you can change it)
- Add the following to a server sided file:
Citizen.CreateThread(function() local uptimeMinute, uptimeHour, uptime = 0, 0, '' while true do Citizen.Wait(1000 * 60) -- every minute uptimeMinute = uptimeMinute + 1 if uptimeMinute == 60 then uptimeMinute = 0 uptimeHour = uptimeHour + 1 end uptime = string.format("%02dh %02dm", uptimeHour, uptimeMinute) SetConvarServerInfo('Uptime', uptime) TriggerClientEvent('uptime:tick', -1, uptime) TriggerEvent('uptime:tick', uptime) end end)