View Issue Details

IDProjectCategoryView StatusLast Update
0008960Multi Theft Auto : San AndreasScriptingpublic2018-09-05 05:31
ReporterGallardo9944 Assigned Toccw  
Status resolvedResolutionfixed 
Fixed in Version1.5 
Summary0008960: Doing maths with getTickCount can return float values

Sometimes doing stuff with getTickCount() returns float values (e.g. calculating time between two ticks). Seems to happen both clientside and serverside. It is absolutely random.

Steps To Reproduce

ER+#666666iGOR executed command: tick = getTickCount()
Command executed!

ER+#666666iGOR executed command: outputChatBox(getTickCount()-tick)

ER+#666666iGOR executed command: outputChatBox(getTickCount()-tick)

ER+#666666iGOR executed command: outputChatBox(getTickCount()-tick)

ER+#666666iGOR executed command: outputChatBox(getTickCount()-tick.." ("..getTickCount().." || "..tick..")")
1686.0000000019 (10748630 || 10746944)

Additional Information

I'm not really sure if it's a problem with maths or getTickCount itself, but that's where I see this every day since official 1.5 release.

TagsNo tags attached.



2015-07-27 11:24

manager   ~~0023724

Last edited: 2015-07-27 11:26

This has existed for as long as I can remember, I've always just used math.floor() to hide it though.

As you've shown though it's not actually a bug with getTickCount() but when Lua does the maths on those large numbers so I don't think it's a bug for MTA to fix.


2015-07-27 12:20

administrator   ~~0023725

Instead, you have to check if the floating point value is within a specified range. See for details.


2015-07-28 16:29

administrator   ~~0023734

Are you sure this happens on the client as well?


2015-07-31 20:46

manager   ~~0023770

Last edited: 2015-07-31 20:51


crun setTimer(function() outputChatBox(getTickCount() - getTickCount() + 1 + 1.0) end, 100, 100)

Returned 2 every time.

Edit: Tried it on server and returns 2 every time as well, though.


2015-08-03 17:06

viewer   ~~0023792

Last edited: 2015-08-03 17:06

It looks like the serverside rounding bug was likely fixed in this commit (r7393):

Issue History

Date Modified Username Field Change