SA-MP Forums Archive
gettickcount or gettime - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: gettickcount or gettime (/showthread.php?tid=649646)



gettickcount or gettime - PepsiCola23 - 12.02.2018

as the title says,which one`s better to use for a command that can be used every 6 hours?


Re: gettickcount or gettime - Mugala - 12.02.2018

gettickcount of course.


Re: gettickcount or gettime - Dayrion - 12.02.2018

Quote:
Originally Posted by Mugala
Посмотреть сообщение
gettickcount of course.
Why?


Re: gettickcount or gettime - PepsiCola23 - 12.02.2018

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


Re: gettickcount or gettime - Abagail - 12.02.2018

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.


Re: gettickcount or gettime - Dayrion - 12.02.2018

Quote:
Originally Posted by Abagail
Посмотреть сообщение
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.


Re: gettickcount or gettime - PepsiCola23 - 12.02.2018

so i should be fine with GetTime?


Re: gettickcount or gettime - AmigaBlizzard - 13.02.2018

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.


Re: gettickcount or gettime - PepsiCola23 - 13.02.2018

ok,i`ll stick to GetTime and store it .


Re: gettickcount or gettime - Gammix - 13.02.2018

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!