General > Developers Corner
Server Uptime
JamminR:
For once, this is one zombie thread I find impressive. Like a good wine, better with age, and improved by the community.
Bryantdl7:
--- Quote from: MrPresident on August 24, 2014, 03:22:58 PM ---
--- Code: ---concommand.Add('uptime', function(ply)
local str = string.format(
'%d:%02d:%02d',
math.floor(CurTime() / 3600),
math.floor(CurTime() % 3600 / 60),
math.floor(CurTime() % 3600 % 60)
)
if IsValid( ply ) then
-- TODO
else
print('Uptime: '..str)
end
end)
if IsValid( ply ) then
-- TODO
else
print('Uptime: '..str)
end
end)
--- End code ---
This only works from the server console, but it should be easy enough to modify it to work for players in game. The check is already there. Just add code where it says -- TODO
--- End quote ---
One year, 2.8 months later; does this look right?
--- Code: ---local uptime = ulx.command( "Utility", "ulx uptime", ulx.uptime, "!uptime" )
local str = string.format(
'%d:%02d:%02d',
math.floor(CurTime() / 3600),
math.floor(CurTime() % 3600 / 60),
math.floor(CurTime() % 3600 % 60)
)
if IsValid( ply ) then
ulx.fancyLogAdmin( calling_ply, "The Server uptime is"..str)
-- TODO
else
print('Uptime: '..str)
end
end)
if IsValid( ply ) then
-- TODO
else
print('Uptime: '..str)
end
end)
--- End code ---
Navigation
[0] Message Index
[*] Previous page
Go to full version