General > Developers Corner
Server Uptime
Bryantdl7:
I feel like an idiot bumping a 7 yr old post... Does this still work? I am trying to find some sort of addon to monitor my server's uptime better than the cvar "stats"
I have a feeling it doesn't but it can't hurt to ask.
Stickly Man!:
Oddly enough, I don't see why it wouldn't work- most of the code used here is basic lua functions- nothing strictly Garrysmod related. Try it and see! :P
Edit: Holy crap, has it been 7 years?!?
MrPresident:
--- 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
Cobalt:
--- 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 ---
I would use SysTime instead of CurTime because it isn't affected by game events such as the timescale changing.
MrPresident:
Good call, never affected me because we don't mess with the timescale, but some people might.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version