AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Closer Timer? (https://forums.alliedmods.net/showthread.php?t=181136)

Gh0$t 03-25-2012 13:15

Closer Timer?
 
Hello!
I need a timer for a climb-server that calculates the time between start and end.
I think about a timer that trigger all 0.1 seconds and calculate per player the current playtime.
This is very computationally intensive for the server, therefore i think its not good.
How can i realize that?
I need a value with double-digit seconds, for example 10.23 seconds.
In PHP i would realize that with microtime(), but i don't found a function like that in SourcePAWN.

RedSword 03-25-2012 13:32

Re: Closer Timer?
 
Use GetEngineTime(). You might want to use GetTickInterval() and the forward OnGameFrame() too.

berni 03-25-2012 16:24

Re: Closer Timer?
 
The most accurate time you can get is with GetGameTime().
GetEngineTime() should only be used for profiling as stated in the API.

Gh0$t 03-25-2012 19:11

Re: Closer Timer?
 
But GetGameTime() returns not the milliseconds, right?

RedSword 03-25-2012 22:23

Re: Closer Timer?
 
Quote:

Originally Posted by berni (Post 1675589)
The most accurate time you can get is with GetGameTime().
GetEngineTime() should only be used for profiling as stated in the API.

Where in the API ?

It is not under GetEngineTime() nor GetGameTime(). I also searched GetGameTime in the wiki and didn't find anything...

necavi 03-25-2012 22:28

Re: Closer Timer?
 
http://docs.sourcemod.net/api/index....ad=show&id=99&

TheAvengers2 03-25-2012 22:31

Re: Closer Timer?
 
The functions aren't mentioned in the wiki.

Float:GetEngineTime()
Quote:

Returns a high-precision time value for profiling the engine.
Float:GetGameTime()
Quote:

Returns the game time based on the game tick.
Edit: looks like necavi beat me to it :P

RedSword 03-26-2012 00:36

Re: Closer Timer?
 
Quote:

Originally Posted by berni (Post 1675589)
The most accurate time you can get is with GetGameTime().
GetEngineTime() should only be used for profiling as stated in the API.

Quote:

Originally Posted by necavi (Post 1675774)
http://docs.sourcemod.net/api/index....ad=show&id=99&
Returns a high-precision time value for profiling the engine.

(doc) For profiling the engine != (berni) only for profiling the engine...

berni 03-26-2012 04:45

Re: Closer Timer?
 
Quote:

Originally Posted by RedSword (Post 1675806)
(doc) For profiling the engine != (berni) only for profiling the engine...

erm do you see other use cases mentioned ? no ? me neither.

The reason why you can't get more accurate than GetGameTime() is because the game is based on frames. The frame rate resolution is usually around ~60 frames / second. 60 frames / second => each 0,0166 seconds a frame is processed. The origin of a player is only updated each frame, there is nothing inbetween. GetEngineTime() is much more accurate, but this accuracy is pretty useless for game stuff because you can only call this function when a frame is processed.

GetGameTime() is what is used in the game's code also internally, it has a resolution of 1 / framerate.


All times are GMT -4. The time now is 19:39.

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