AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Is there a way I could get the servers uptime? (https://forums.alliedmods.net/showthread.php?t=2373)

Dygear 06-02-2004 23:20

Is there a way I could get the servers uptime?
 
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.

ts2do 06-02-2004 23:22

isnt it just halflife_time?

PM 06-03-2004 05:44

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

Dygear 06-03-2004 22:26

Thanks :D

Downtown1 06-03-2004 22:41

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.

Dygear 06-03-2004 22:54

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 06-03-2004 23:53

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.

PM 06-04-2004 06:52

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

Dygear 06-04-2004 16:42

Thank you soo much, this has been a great help.

Girthesniper 06-04-2004 17:56

Can you post the plugin. Make it like "thetime" plugin. but only do "theuptime" ;).


All times are GMT -4. The time now is 14:38.

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