AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Suggestions / Requests (https://forums.alliedmods.net/forumdisplay.php?f=12)
-   -   finding server uptime (https://forums.alliedmods.net/showthread.php?t=308616)

csykosoma 06-27-2018 11:52

finding server uptime
 
I am wanting to check the total server up time and compare it to a value, and if value exceed will execute some code. "stats" gives the uptime, but how would you retrieve this?

edon1337 06-27-2018 12:11

Re: finding server uptime
 
PHP Code:

#include < amxmodx >

new g_iUpTime;

new const 
g_szLogFile[ ] = "ServerUptime.txt";

public 
plugin_init( )
{
    
register_plugin"Server Uptime Calculator""1.0""DoNii" );
    
set_task1.0"ServerRun"666__"b" );
}

public 
plugin_end( )
{
    
remove_task666 );

    
log_to_fileg_szLogFile"Server has been running for: %d seconds, %d hours, %d days"g_iUpTimeSecondsToHoursg_iUpTime ), SecondsToDaysg_iUpTime ) );
}

public 
ServerRun( )
{
    
g_iUpTime += 1;
}

SecondsToHoursiValue )
{
    return ( 
iValue 3600 );
}

SecondsToDaysiValue )
{
    return ( 
iValue 86400 );



Ghosted 06-27-2018 12:52

Re: finding server uptime
 
Quote:

Originally Posted by edon1337 (Post 2599536)
PHP Code:

#include < amxmodx >

new g_iUpTime;

new const 
g_szLogFile[ ] = "ServerUptime.txt";

public 
plugin_init( )
{
    
register_plugin"Server Uptime Calculator""1.0""DoNii" );
    
set_task1.0"ServerRun"666__"b" );
}

public 
plugin_end( )
{
    
remove_task666 );

    
log_to_fileg_szLogFile"Server has been running for: %d seconds, %d hours, %d days"g_iUpTimeSecondsToHoursg_iUpTime ), SecondsToDaysg_iUpTime ) );
}

public 
ServerRun( )
{
    
g_iUpTime += 1;
}

SecondsToHoursiValue )
{
    return ( 
iValue 3600 );
}

SecondsToDaysiValue )
{
    return ( 
iValue 86400 );




666 ? huh? I smell hell.

Ghosted 06-28-2018 04:39

Re: finding server uptime
 
That task will be called in every second, why u need that when u have gpGlobals time variable

edon1337 06-28-2018 06:32

Re: finding server uptime
 
Quote:

Originally Posted by Ghosted (Post 2599661)
That task will be called in every second, why u need that when u have gpGlobals time variable

What?

Ghosted 06-28-2018 07:47

Re: finding server uptime
 
Quote:

Originally Posted by edon1337 (Post 2599677)
What?

[C++] gpGlobals is "default" name of global settings variable. (In amxx you can use native global_get to get those settings & one of them is time).

^SmileY 06-28-2018 08:21

Re: finding server uptime
 
You can use hlds logs to archive this, do not need an plugin


All times are GMT -4. The time now is 00:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.