Raised This Month: $12 Target: $400
 3% 

Closer Timer?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Gh0$t
Senior Member
Join Date: Mar 2010
Location: Germany at 127.0.0.1
Old 03-25-2012 , 13:15   Closer Timer?
Reply With Quote #1

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.
__________________
Gh0$t is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 03-25-2012 , 13:32   Re: Closer Timer?
Reply With Quote #2

Use GetEngineTime(). You might want to use GetTickInterval() and the forward OnGameFrame() too.
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 03-25-2012 at 13:32.
RedSword is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 03-25-2012 , 16:24   Re: Closer Timer?
Reply With Quote #3

The most accurate time you can get is with GetGameTime().
GetEngineTime() should only be used for profiling as stated in the API.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0
berni is offline
Gh0$t
Senior Member
Join Date: Mar 2010
Location: Germany at 127.0.0.1
Old 03-25-2012 , 19:11   Re: Closer Timer?
Reply With Quote #4

But GetGameTime() returns not the milliseconds, right?
__________________
Gh0$t is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 03-25-2012 , 22:23   Re: Closer Timer?
Reply With Quote #5

Quote:
Originally Posted by berni View Post
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...
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work
RedSword is offline
necavi
Veteran Member
Join Date: Sep 2010
Old 03-25-2012 , 22:28   Re: Closer Timer?
Reply With Quote #6

http://docs.sourcemod.net/api/index....ad=show&id=99&
necavi is offline
TheAvengers2
BANNED
Join Date: Jul 2011
Old 03-25-2012 , 22:31   Re: Closer Timer?
Reply With Quote #7

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

Last edited by TheAvengers2; 03-25-2012 at 22:31.
TheAvengers2 is offline
RedSword
SourceMod Plugin Approver
Join Date: Mar 2006
Location: Quebec, Canada
Old 03-26-2012 , 00:36   Re: Closer Timer?
Reply With Quote #8

Quote:
Originally Posted by berni View Post
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 View Post
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...
__________________
My plugins :
Red Maze
Afk Bomb
RAWR (per player/rounds Awp Restrict.)
Kill Assist
Be Medic

You can also Donate if you appreciate my work

Last edited by RedSword; 03-26-2012 at 00:36.
RedSword is offline
berni
SourceMod Plugin Approver
Join Date: May 2007
Location: Austria
Old 03-26-2012 , 04:45   Re: Closer Timer?
Reply With Quote #9

Quote:
Originally Posted by RedSword View Post
(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.
__________________
Why reinvent the wheel ? Download smlib with over 350 useful functions.

When people ask me "Plz" just because it's shorter than "Please" I feel perfectly justified to answer "No" because it's shorter than "Yes"
powered by Core i7 3770k | 32GB DDR3 1886Mhz | 2x Vertex4 SSD Raid0

Last edited by berni; 03-26-2012 at 04:46.
berni is offline
Reply


Thread Tools
Display Modes

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 18:05.


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