Raised This Month: $ Target: $400
 0% 

finding server uptime


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
csykosoma
Member
Join Date: Dec 2011
Old 06-27-2018 , 11:52   finding server uptime
Reply With Quote #1

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?
csykosoma is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 06-27-2018 , 12:11   Re: finding server uptime
Reply With Quote #2

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 );

__________________

Last edited by edon1337; 06-27-2018 at 12:15.
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 06-27-2018 , 12:52   Re: finding server uptime
Reply With Quote #3

Quote:
Originally Posted by edon1337 View Post
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.
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 06-28-2018 , 04:39   Re: finding server uptime
Reply With Quote #4

That task will be called in every second, why u need that when u have gpGlobals time variable
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM
Ghosted is offline
edon1337
Penguin Enthusiast
Join Date: Jun 2016
Location: Macedonia
Old 06-28-2018 , 06:32   Re: finding server uptime
Reply With Quote #5

Quote:
Originally Posted by Ghosted View Post
That task will be called in every second, why u need that when u have gpGlobals time variable
What?
__________________
edon1337 is offline
Ghosted
Veteran Member
Join Date: Apr 2015
Location: Georgia
Old 06-28-2018 , 07:47   Re: finding server uptime
Reply With Quote #6

Quote:
Originally Posted by edon1337 View Post
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).
__________________

[MOD] CS Weapon Mod V1.7.1
[MM] MetaMod-C V1.0
[MOD] CS NPC Mod (5%)


Probably Left AM

Last edited by Ghosted; 06-28-2018 at 07:48.
Ghosted is offline
^SmileY
Veteran Member
Join Date: Jan 2010
Location: Brazil [<o>]
Old 06-28-2018 , 08:21   Re: finding server uptime
Reply With Quote #7

You can use hlds logs to archive this, do not need an plugin
__________________
Projects:

- See my Git Hub: https://github.com/SmileYzn
PHP Code:
set_pcvar_num(pCvar, !get_pcvar_num(pCvar)); 
^SmileY is offline
Send a message via MSN to ^SmileY Send a message via Skype™ to ^SmileY
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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