Raised This Month: $ Target: $400
 0% 

get uptime [solved solved solved]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-28-2007 , 03:22   get uptime [solved solved solved]
Reply With Quote #1

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
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME

Last edited by kp_uparrow; 08-01-2007 at 20:02.
kp_uparrow is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-28-2007 , 15:34   Re: get uptime
Reply With Quote #2

Why not store get_systime() at server start and calculate it from that?
Lee is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-28-2007 , 21:22   Re: get uptime
Reply With Quote #3

oh boy i guess this is no get uptime

systime then i would have to do all those differnt calculations

thx anyways
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 07-28-2007 , 22:01   Re: get uptime
Reply With Quote #4

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

Last edited by Lee; 07-29-2007 at 01:55.
Lee is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 07-29-2007 , 07:40   Re: get uptime
Reply With Quote #5

The most simple way would be: new Float:uptime = engfunc(EngFunc_Time)
VEN is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-29-2007 , 17:42   Re: get uptime
Reply With Quote #6

which one do i try? lee or ven? ill try lee's
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-30-2007 , 02:05   Re: get uptime
Reply With Quote #7

VEN's suggestion works fine!
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-30-2007 , 14:41   Re: get uptime
Reply With Quote #8

ven's give me this:

uptime 1127667941
while the actual uptime is 3
??
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 07-30-2007 , 14:46   Re: get uptime
Reply With Quote #9

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)
}
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 07-30-2007 , 16:39   Re: get uptime
Reply With Quote #10

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)
VEN is offline
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 07:58.


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