AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get_gametime() (https://forums.alliedmods.net/showthread.php?t=48295)

[ --<-@ ] Black Rose 12-09-2006 13:45

get_gametime()
 
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) }

schnitzelmaker 12-09-2006 13:50

Re: get_gametime()
 
change a little your plugin
Code:
server_print("diff = %f,%f,%f", diff,start,stop)

[ --<-@ ] Black Rose 12-09-2006 13:59

Re: get_gametime()
 
diff = 0.000000,2.049999,2.049999

..so how would i do this, since this way doesn't work?

XxAvalanchexX 12-09-2006 15:21

Re: get_gametime()
 
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".

[ --<-@ ] Black Rose 12-09-2006 15:33

Re: get_gametime()
 
the file is long enough... 5k lines.
i will try get_systime(). thx.

VEN 12-09-2006 15:41

Re: get_gametime()
 
The server is "freezed" when executing something, so gametime are "freezed" too.

[ --<-@ ] Black Rose 12-09-2006 16:03

Re: get_gametime()
 
Quote:

Originally Posted by VEN (Post 412883)
The server is "freezed" when executing something, so gametime are "freezed" too.

Yeah, thats what I thought.


All times are GMT -4. The time now is 06:50.

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