View Issue Details Jump to Notes ] Issue History ] Print ]
IDProjectCategoryView StatusDate SubmittedLast Update
0008482New issuesClientpublic2014-08-21 08:432017-05-13 22:43
Assigned To 
Platform64-bitOSWindowsOS Version8.1 Pro
Summary0008482: MTA internal functions returning NaN values
DescriptionI am running a script, which gets the position coordinates from getPedTargetCollision and getPedTargetEnd and sometimes passing directly those positions to another MTA function (examples: dxDrawLine3D, createMarker) I get this: "WARNING: resource/client.lua:line: Bad argument @ 'dxDrawLine3D' [Expected number, got NaN]
TagsNo tags attached.
Attached Files

- Relationships
related to 0004504confirmed Multi Theft Auto : San Andreas Peds shooting incorrectly 

-  Notes
Buffalo (viewer)
2014-08-25 23:56

I can confirm that there is issue with NaN's. Had to check for NaN's to avoid warnings.

Code [^]

Never had warnings with earlier MTA versions
Grafu (viewer)
2014-08-26 07:18

I wouldn't trust your code. It does a lot of transformations and might do a calculation mistake. The thing I am talking about is getting NaN values from internal functions.
arranTuna (manager)
2014-08-27 01:16

I've got a script which:

local x, y, z = getPedWeaponMuzzlePosition(plr)
local x2, y2, z2 = getPedTargetEnd(plr)
dxDrawLine3D(x, y, z, x2, y2, z2, color, 1, false)

and it's said NaN for 3 frames just now and once or twice before so it does happen but it's extremely rare.
Buffalo (viewer)
2014-08-27 02:03

Well the point is, these transformations worked fine earlier, Grafu.
qaisjp (administrator)
2014-08-27 02:18

What numbers do you get if you dump all the data whenever it is NaN? Does it occur randomly or does it only occur with certain inputs/outputs
Grafu (viewer)
2014-08-27 09:20
edited on: 2014-09-18 21:43

Caught a NaN from getPedTargetEnd: -1.#IND

Sometimes getting this as x position, sometimes as y and sometimes as both. Yeah, it occurs with the input 'localPlayer'.

arranTuna (manager)
2014-09-21 15:02

Just thought I'd mention that this is similar to when these functions would return values like 2347835718234 which meant that processLineOfSight would freeze the game for an hour.

Also an efficient check for NaNs (you can put it in bone_attach):

not string.find(objx..objy..objz..offrx..offry..offrz, "#")
arranTuna (manager)
2014-11-24 14:17

Need a list of these functions.

getPedTargetEnd is definitely one of them.
einheit-101 (reporter)
2016-03-30 12:27
edited on: 2016-03-30 13:01

€DIT: onClientPlayerWeaponFire hitX, hitY or hitZ confirmed to return NaN, very rare. I get the NaN debug in getWaterLevel(hx, hy, hz)

I will investigate this further

IIYAMA12 (viewer)
2016-03-30 13:49
edited on: 2016-03-30 17:32

> It is very common to get a nan value when you divide a number value by zero.

The function getPedTargetEnd will be (nan or nil)* when the player isn't aiming correctly. *Depending on the scenario.

einheit-101 (reporter)
2016-03-31 02:12

I caught it freshly here: [^]

addEventHandler ( "onClientPlayerWeaponFire", root, gunfire )
einheit-101 (reporter)
2017-05-13 16:27

I have a skin here, where "getPedBonePosition" returns nan (ind) every 2nd frame onClientPreRender for all xyz positions, at least for bone 3. Very Strange.
arranTuna (manager)
2017-05-13 22:33

Modded skin? It could be a buggy skin mod. I remember a similar problem which I think was related to a buggy skin that returned a super huge number (or inf) I guess from getPedBonePosition which then caused a script using processLineOfSight / isLineOfSightClear to freeze for many minutes because it was processing this extremely long distance. So a distance limit was added.
einheit-101 (reporter)
2017-05-13 22:43

Yes, its a modded skin, however I don't know why it is causing that issue since it is pretty much like all other skins. I am already re-rigging it to prevent this bug from happening, however even fine skins can still randomly return nan.

- Issue History
Date Modified Username Field Change
2014-08-21 08:43 Grafu New Issue
2014-08-21 23:32 Dutchman101 Note Added: 0021831
2014-08-22 04:40 ccw Note Deleted: 0021831
2014-08-25 23:56 Buffalo Note Added: 0021865
2014-08-26 07:18 Grafu Note Added: 0021866
2014-08-27 01:16 arranTuna Note Added: 0021873
2014-08-27 02:03 Buffalo Note Added: 0021874
2014-08-27 02:18 qaisjp Note Added: 0021875
2014-08-27 09:20 Grafu Note Added: 0021878
2014-08-27 09:30 Grafu Note Edited: 0021878 View Revisions
2014-08-27 09:36 Grafu Note Edited: 0021878 View Revisions
2014-09-18 21:42 Grafu Note Edited: 0021878 View Revisions
2014-09-18 21:43 Grafu Note Edited: 0021878 View Revisions
2014-09-21 15:02 arranTuna Note Added: 0022036
2014-11-24 14:17 arranTuna Note Added: 0022585
2014-11-24 14:17 arranTuna Status new => feedback
2014-11-24 14:18 arranTuna Relationship added related to 0004504
2016-03-30 12:27 einheit-101 Note Added: 0024575
2016-03-30 12:36 einheit-101 Note Edited: 0024575 View Revisions
2016-03-30 13:01 einheit-101 Note Edited: 0024575 View Revisions
2016-03-30 13:49 IIYAMA12 Note Added: 0024576
2016-03-30 17:32 IIYAMA12 Note Edited: 0024576 View Revisions
2016-03-31 02:12 einheit-101 Note Added: 0024577
2017-05-13 16:27 einheit-101 Note Added: 0025943
2017-05-13 22:33 arranTuna Note Added: 0025944
2017-05-13 22:43 einheit-101 Note Added: 0025945

Copyright © 2000 - 2017 MantisBT Team
Powered by Mantis Bugtracker