Thread: Server Uptime
View Single Post
Impact123
Veteran Member
Join Date: Oct 2011
Location: Germany
Old 04-05-2012 , 03:19   Re: Server Uptime
Reply With Quote #3

@Doodil

Just one proposal:
PHP Code:
#include <sourcemod>
#pragma semicolon 1


public OnPluginStart()
{
    
RegConsoleCmd("sm_uptime"Command_Time);
}



public 
Action:Command_Time(clientargs)
{
    new 
Float:theTime GetGameTime();
    new 
days          RoundToZero(theTime 86400);
    new 
hours         RoundToZero( (theTime-days) / 3600);
    new 
minutes       RoundToZero( (theTime-days-hours)/60);
    new 
seconds       RoundToZero(theTime days hours minutes);
    new 
milli         RoundToZero( (theTime days hours minutes seconds) * 1000);
    
    
    if(
client && client <= MAXPLAYERS && IsClientInGame(client))
    {
        
PrintToChat(client"\x03Uptime: %d days %d hours %d minutes %d seconds and %d milliseconds"dayshoursminutessecondsmilli);
    }
    else if(
client == 0)
    {
        
PrintToServer("Uptime: %d days %d hours %d minutes %d seconds and %d milliseconds"dayshoursminutessecondsmilli);
    }
    
    return 
Plugin_Handled;

@Privet1337
Note that GetGameTime() does not count until there are/was players in the server.

Yours sincerely
Impact
__________________

Last edited by Impact123; 04-05-2012 at 03:24.
Impact123 is offline