Raised This Month: $ Target: $400
 0% 

get_gametime()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-09-2006 , 13:45   get_gametime()
Reply With Quote #1

It would just print out "diff = 0.000"
Whats wrong?
Code:
public plugin_init() {     register_plugin("test", "1.00", "[ --<-@ ]")     set_task(1.0, "test") } public test() {     start_timer()         new text1[32]         new i_file = fopen("addons/amxmodx/test.txt", "r");     new i_file2 = fopen("addons/amxmodx/result1.txt", "w");         if ( ! i_file )         return;         while ( ! feof(i_file) ) {         fgets(i_file, text1, 31);         fprintf(i_file2, "%s", text1)     }         fclose(i_file);     fclose(i_file2);         stop_timer() } new Float:start, Float:stop public start_timer()     start = get_gametime()     public stop_timer() {     stop = get_gametime()     new Float:diff = floatsub(start, stop)     server_print("diff = %f", diff) }

Last edited by [ --<-@ ] Black Rose; 12-09-2006 at 13:48.
[ --<-@ ] Black Rose is offline
schnitzelmaker
Senior Member
Join Date: Apr 2006
Location: HERE
Old 12-09-2006 , 13:50   Re: get_gametime()
Reply With Quote #2

change a little your plugin
Code:
server_print("diff = %f,%f,%f", diff,start,stop)
__________________
schnitzelmaker is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-09-2006 , 13:59   Re: get_gametime()
Reply With Quote #3

diff = 0.000000,2.049999,2.049999

..so how would i do this, since this way doesn't work?
[ --<-@ ] Black Rose is offline
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 12-09-2006 , 15:21   Re: get_gametime()
Reply With Quote #4

You could try get_systime instead. Are you sure the file is actually long enough to take more than one second to read through?

Also, you don't need to use floatsub, it is automatically done for you when two floats are subtracted. Just use "stop - start".
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-09-2006 , 15:33   Re: get_gametime()
Reply With Quote #5

the file is long enough... 5k lines.
i will try get_systime(). thx.
[ --<-@ ] Black Rose is offline
VEN
Veteran Member
Join Date: Jan 2005
Old 12-09-2006 , 15:41   Re: get_gametime()
Reply With Quote #6

The server is "freezed" when executing something, so gametime are "freezed" too.
VEN is offline
[ --<-@ ] Black Rose
ANNIHILATED
Join Date: Sep 2005
Location: Stockholm, Sweden.
Old 12-09-2006 , 16:03   Re: get_gametime()
Reply With Quote #7

Quote:
Originally Posted by VEN View Post
The server is "freezed" when executing something, so gametime are "freezed" too.
Yeah, thats what I thought.
[ --<-@ ] Black Rose 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 06:50.


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