AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get uptime [solved solved solved] (https://forums.alliedmods.net/showthread.php?t=58516)

kp_uparrow 07-28-2007 03:22

get uptime [solved solved solved]
 
how do i get the uptime that the server has been running, not how long this map has been or the system time, i want the time since hlds.exe was launched

Lee 07-28-2007 15:34

Re: get uptime
 
Why not store get_systime() at server start and calculate it from that?

kp_uparrow 07-28-2007 21:22

Re: get uptime
 
oh boy i guess this is no get uptime

systime then i would have to do all those differnt calculations

thx anyways

Lee 07-28-2007 22:01

Re: get uptime
 
I haven't tested this, but it definitely doesn't involve anything remotely complex.. You could also use set_localinfo() rather than a cvar.

Code:
new g_StartTime; public plugin_init() {     g_StartTime = register_cvar("server_start_time", "%i", get_systime()); } myFunc() {     new upTime = get_systime() - get_pcvar_num(g_StartTime);         client_print(0, print_chat, "Uptime in seconds: %i", upTime);     client_print(0, print_chat, "Uptime in minutes: %i:%i", upTime / 60, upTime % 60);     client_print(0, print_chat, "Uptime in hours: %i:%i", upTime / 3600, upTime / 60); }

VEN 07-29-2007 07:40

Re: get uptime
 
The most simple way would be: new Float:uptime = engfunc(EngFunc_Time)

kp_uparrow 07-29-2007 17:42

Re: get uptime
 
which one do i try? lee or ven? ill try lee's

Alka 07-30-2007 02:05

Re: get uptime
 
VEN's suggestion works fine! :wink:

kp_uparrow 07-30-2007 14:41

Re: get uptime
 
ven's give me this:

uptime 1127667941
while the actual uptime is 3
??

kp_uparrow 07-30-2007 14:46

Re: get uptime
 
lee the "server_start_time" is "%i" LOL

works fine when i go:

new zomg=get_systime()
st = register_cvar("server_start_time", "0");
if(get_pcvar_num(st)==0){
server_cmd("server_start_time %d",zomg)
}

VEN 07-30-2007 16:39

Re: get uptime
 
Quote:

ven's give me this:

uptime 1127667941
while the actual uptime is 3
??
It's a float value.

Correct: server_print("%f", uptime)

Incorrect: server_print("%d", uptime)

Incorrect: server_print("%i", uptime)


All times are GMT -4. The time now is 07:58.

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