NetworkGetPlayerIndexFromPed - nil native

Hey! We’ve noticed native being nil on the latest Canary/Beta version of FiveM

Some important info + repro steps

  1. Client - Beta (5413); Server - 5374
  2. Expected to get player id of ped, as native is supposed to.
  3. Error is being thrown, attempt to call a nil value (global ‘NetworkGetPlayerIndexFromPed’)
  4. Native
  5. Code snippet below.
local playerPed = PlayerPedId()
local playerId = NetworkGetPlayerIndexFromPed(playerPed) -- error thrown here
local playerName = GetPlayerName(playerId)

print('Player name is:', playerName)

attach.rar (396 Bytes)

Native link: NetworkGetPlayerIndexFromPed - FiveM Natives @ Cfx.re Docs
Screenshot of error

Oddly, this snippet seems to work fine here:

However, there does seem to be a scenario where Lua scripts that use an ancient resource manifest version (deprecated since… mid-2017?) that try to access a function by a name not defined at the time may ‘leak’ this state persisting for other resources as well.

Weird…

This issue is happening across multiple of our servers and multiple clients (all of them using Beta/Latest build)
Resources this is happening in are mostly using ‘adamant’ or ‘cerulean’ fx_version.

Could presence of few resources with old __resource manifest cause this issue server-wide?

Additionally, I can try running some tests on empty server.

Also, this started happening ± after this commit:

But that wouldn’t explain the native function being nil…

If these also do not specify any (or the initial, low) resource manifest version, yes.

Ok, is there any further testing needed or can I mark this as solved?

I can see that you already did some fixing, which is working on the Latest (Unstable) FiveM build.