Raised This Month: $ Target: $400
 0% 

Is there a way I could get the servers uptime?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 06-02-2004 , 23:20   Is there a way I could get the servers uptime?
Reply With Quote #1

I am trying to make a plugin that will log the servers uptime, but have hit a wall, i have the command to find when the server is shutdown[plugin_end()], now i need a command to tell when the server starts up!

I am then going to use this and find the uptime by taking when the server started, lets call that S, and when the server ended, lets call that E and by taking away S from E i will get the uptime or T.

S-E=T

Please do not lock this post, i will have more qustions when this is answered.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
ts2do
Senior Member
Join Date: Mar 2004
Old 06-02-2004 , 23:22  
Reply With Quote #2

isnt it just halflife_time?
__________________
ts2do is offline
Send a message via AIM to ts2do
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-03-2004 , 05:44  
Reply With Quote #3

1) Yes, halflife_time should return the amount of seconds since the map start (as a float).
2) The command which gets called when the map starts is plugin_init.
3) If you want to know the server's total uptime, you could write the map time to a vault in plugin_end and load it again in plugin_init. If the difference is smaller than 30 seconds, you could assume that the server did not crash
__________________
hello, i am pm
PM is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 06-03-2004 , 22:26  
Reply With Quote #4

Thanks
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Downtown1
Veteran Member
Join Date: Mar 2004
Old 06-03-2004 , 22:41  
Reply With Quote #5

Also, for times it crashes in the middle of the map this is what you could do:

Well, when a server crashes the plugin_end() wouldn't execute right?

So each time plugin_end() executes, you could write something to vault saying that the server successfully shut down the map.

Now if it crashes after a map change, it's usually to a bad WAD file or too many precached textures, in which case (at least on Windows) the server will not automatically restart until someone hits "OK" for the error message, so you could just compare the time it takes for the map to change like PM said.
Downtown1 is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 06-03-2004 , 22:54  
Reply With Quote #6

Ya see this is what i am going to do to contend with that, if there are two start lines in the vault then i know the server crashed between these times .
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 06-03-2004 , 23:53  
Reply With Quote #7

Ok found halflife_time() in engine.inc, but is there a specific way i must handel floats?

Code:
/* Gets gpGlobals->time from Half-Life */ native Float:halflife_time();

Ok so ... give me a block of code on how i should go about this, please.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 06-04-2004 , 06:52  
Reply With Quote #8

Code:
new Float:time = halflife_time(); // guess you won't do this, but it is a nice example for format strings with floats :D log_amx("The time is: %f", time);
__________________
hello, i am pm
PM is offline
Dygear
SourceMod Donor
Join Date: Apr 2004
Location: Levittown, NY
Old 06-04-2004 , 16:42  
Reply With Quote #9

Thank you soo much, this has been a great help.
__________________
Dygear is offline
Send a message via AIM to Dygear Send a message via MSN to Dygear Send a message via Skype™ to Dygear
Girthesniper
Senior Member
Join Date: Mar 2004
Location: Maryland
Old 06-04-2004 , 17:56  
Reply With Quote #10

Can you post the plugin. Make it like "thetime" plugin. but only do "theuptime" ;).
__________________
BANNED
Girthesniper is offline
Send a message via AIM to Girthesniper Send a message via MSN to Girthesniper
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 14:38.


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