View Issue Details

IDProjectCategoryView StatusLast Update
0008482New issuesClientpublic2017-05-13 22:43
ReporterGrafuAssigned To 
PrioritynormalSeverityminorReproducibilitysometimes
Status feedbackResolutionopen 
Platform64-bitOSWindowsOS Version8.1 Pro
Summary0008482: MTA internal functions returning NaN values
Description

I 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.

Relationships

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

Activities

Buffalo

2014-08-25 23:56

viewer   ~~0021865

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

Code http://pastebin.com/cWrjhicm

Never had warnings with earlier MTA versions

Grafu

2014-08-26 07:18

viewer   ~~0021866

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

2014-08-27 01:16

manager   ~~0021873

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

2014-08-27 02:03

viewer   ~~0021874

Well the point is, these transformations worked fine earlier, Grafu.

qaisjp

2014-08-27 02:18

administrator   ~~0021875

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

2014-08-27 09:20

viewer   ~~0021878

Last edited: 2014-09-18 21:43

View 5 revisions

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

2014-09-21 15:02

manager   ~~0022036

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

2014-11-24 14:17

manager   ~~0022585

Need a list of these functions.

getPedTargetEnd is definitely one of them.

einheit-101

2016-03-30 12:27

reporter   ~~0024575

Last edited: 2016-03-30 13:01

View 3 revisions

€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

2016-03-30 13:49

viewer   ~~0024576

Last edited: 2016-03-30 17:32

View 2 revisions

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

2016-03-31 02:12

reporter   ~~0024577

I caught it freshly here:
http://i.imgur.com/vwIpd8Y.jpg

addEventHandler ( "onClientPlayerWeaponFire", root, gunfire )

einheit-101

2017-05-13 16:27

reporter   ~~0025943

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

2017-05-13 22:33

manager   ~~0025944

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

2017-05-13 22:43

reporter   ~~0025945

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