Using FiveM natives but gets "get attempt to call nil value (global '<NATIVE>')"

Hi there everyone,

I am not primarily coding in Lua, but I have noticed this for the second time now. I am using a simple native that shouldn’t require any parameters/variables, but somehow it returns with an error that says:

attempt to call nil value (global '<NATIVE>')

It is like my Lua code is trying to reach for a function that does not exist when I am trying to use a native?

I have tried this with InvalidateIdleCam() and one of the StartShapeTestLosProbe() or something. I don’t know what is causing this because sometimes it works in other scripts so maybe I am doing something wrong that I am not aware of.

I have this code where it happens:

local MenuActive = false
function OpenMenu(Type)
	ESX.UI.Menu.CloseAll()
	local elements = {}
	if Type == 'clothingshop' then
		SetNuiFocus(true, true)
		SendNUIMessage({type = 'bbdClothingshopMenu'})
		MenuActive = true
	end
end

Citizen.CreateThread(function() 
	while true do
		Wait(1000) --The idle camera activates after 30 second so we don't need to call this per frame
		if MenuActive then
			InvalidateIdleCam()
			N_0x9e4cfff989258472() --Disable the vehicle idle camera
			print("Disabling idle cam.")
		end
	end 
end)

This returns an error that says:

attempt to call a nil value (global 'InvalidateIdleCam')

So am I doing something wrong or some workaround?

Best regards & thanks in advance,
bilbodog

I have also just tried this and this fails as well:

local MenuActive = true
Citizen.CreateThread(function() 
	while true do
		Wait(1000) --The idle camera activates after 30 second so we don't need to call this per frame
		if MenuActive then
			InvalidateIdleCam()
			N_0x9e4cfff989258472() --Disable the vehicle idle camera
			print("Disabling idle cam.")
		end
	end 
end)

Comes with the same error:

attempt to call a nil value (global 'InvalidateIdleCam')

Make sure you are using fxmanifest.lua as resource manifest with fx_version 'adamant' so you are using the latest native codegen

What does the function InvalidateIdleCam do? as thats the issue,

@Dutchkiller2000 Not sure what you meant with the above, as you can see its clear that that disables something else, because others don’t have it in their code does not mean he cant have it, how else are people going to be making unique scripts?

if you took the time to actually read the above snippets

N_0x9e4cfff989258472() --Disable the vehicle idle camera

You could see what this does, next time take some time before replying on something u have no clue about.

Doesn’t seem very related to ‘InvalidateIdleCam’ being a nil value

It was just a suggestion mate. Because the native doesnt have a name or a description on the natives site i thought that may cause the error above because there are no lines given of the error

2 Likes

I took it from: InvalidateIdleCam - FiveM Natives @ Cfx.re Docs
It should:

Resets the idle camera timer. Calling this in a loop will disable the idle camera.

The line:

N_0x9e4cfff989258472() --Disable the vehicle idle camera

It is just for vehicles.

The exact line the error gives is the same line where “InvalidateIdleCam()”

What do you mean? The code you just linked have this in their code? :upside_down_face:

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1000)
		if menuactive then InvalidateIdleCam() end
	end
end)

Actually almost same as me.

1 Like

Can we see your __resource.lua in the meanwhile, i’m writing up a quick script locally to see what the cause could be.

Exactly, that is what I figured as well. It is like it is trying to call a function, but there are no function called that, it is a FiveM/GTA native that I am trying to call.

But right now I am trying to update the manifest, where can I see the latest manifest version, @TheIndra ?

The whole thing ended up being the “resource_manifest_version” that needed to be updated. Thx a lot. :smiley:

I am very grateful.

as an addition to that, u may want to try to use the newest stuff.

Thanks a lot.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.