SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 12/02/2018, 05:55 PM   #1
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 680
Reputation: 3
Default gettickcount or gettime

as the title says,which one`s better to use for a command that can be used every 6 hours?
PepsiCola23 is offline   Reply With Quote
Old 12/02/2018, 05:57 PM   #2
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 635
Reputation: 30
Default Re: gettickcount or gettime

gettickcount of course.
__________________
here to help
Mugala is offline   Reply With Quote
Old 12/02/2018, 06:02 PM   #3
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,771
Reputation: 230
Default Re: gettickcount or gettime

Quote:
Originally Posted by Mugala View Post
gettickcount of course.
Why?
__________________
actor_plus - v4.1.2
« I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath »
Dayrion is online now   Reply With Quote
Old 12/02/2018, 06:06 PM   #4
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 680
Reputation: 3
Default Re: gettickcount or gettime

some people recommended gettime for the things more than a second because it returns the time in seconds.
i just wanted to hear more thoughts about this
PepsiCola23 is offline   Reply With Quote
Old 12/02/2018, 06:09 PM   #5
Abagail
High-roller
 
Join Date: Dec 2013
Location: GetPlayerPos(playerid, pos); Scripter/Mapper.
Posts: 3,525
Reputation: 437
Default Re: gettickcount or gettime

GetTickCount should be fine for use, although it won't persist properly across server restarts/crashes as the count will reset. If you save the value, use gettime.
Abagail is offline   Reply With Quote
Old 12/02/2018, 09:17 PM   #6
Dayrion
High-roller
 
Dayrion's Avatar
 
Join Date: Jan 2016
Location: France
Posts: 1,771
Reputation: 230
Default Re: gettickcount or gettime

Quote:
Originally Posted by Abagail View Post
GetTickCount should be fine for use, although it won't persist properly across server restarts/crashes as the count will reset. If you save the value, use gettime.
Exactly. Plus if you run your server for more than 24h you will occur some problem with gettick.
__________________
actor_plus - v4.1.2
« I'm a goner, somebody catch my breath,
I'm a goner, somebody catch my breath »
Dayrion is online now   Reply With Quote
Old 12/02/2018, 09:18 PM   #7
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 680
Reputation: 3
Default Re: gettickcount or gettime

so i should be fine with GetTime?
PepsiCola23 is offline   Reply With Quote
Old 13/02/2018, 07:58 PM   #8
AmigaBlizzard
Huge Clucker
 
Join Date: Jul 2012
Posts: 286
Reputation: 50
Default Re: gettickcount or gettime

If you really need the time to be accurate up to a millisecond, use GetTickCount.
But you can get problems if your server keeps running for more than 2.1 billion milliseconds (= 2.1 million seconds = 35791 minutes = 596 hours = 24 days) because of integer-overflow, the value gets negative and might mess up your entire code.

But in your case, a time of about 6 hours, it won't need that much accuracy so GetTime (which is accurate up to a second) is sufficient.
AmigaBlizzard is offline   Reply With Quote
Old 13/02/2018, 08:20 PM   #9
PepsiCola23
Gangsta
 
Join Date: May 2015
Posts: 680
Reputation: 3
Default Re: gettickcount or gettime

ok,i`ll stick to GetTime and store it .
PepsiCola23 is offline   Reply With Quote
Old 13/02/2018, 08:50 PM   #10
Gammix
High-roller
 
Gammix's Avatar
 
Join Date: Jan 2015
Location: Canada
Posts: 1,726
Reputation: 780
Default Re: gettickcount or gettime

GetTickCount() -> milliseconds
gettime() -> seconds

If you are not dealing in milliseconds, use gettime(). GetTickCount() is usually used for benchmarks.

Edit: Didn't see AmigaBlizzard's reply, but now you have two explanations implying the right method to use!
__________________
Gammix is offline   Reply With Quote
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Ajuda] getdate, gettime ou gettickcount B4dB0y Português/Portuguese 1 21/08/2013 12:42 AM
Some differences, GettickCount, Gettime, TickCount ? NewbieScripter Scripting Help 1 26/08/2012 07:35 PM
Question Help: Command limited, with gettickcount or gettime Speed++ Scripting Help 34 30/07/2012 11:48 PM
GetTickCount ? [D]ry[D]esert Scripting Help 10 25/05/2012 01:46 PM
GetTickCount Agent Smith Help Archive 7 23/07/2010 12:01 AM


All times are GMT. The time now is 03:37 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.