Attempt to call a table value Es_extended - functions.lua:422

Hi guys, my problem is the following, I put a taxi job to my localhost, so when executing my f6 menu, to activate the passenger NPC mode, it practically gives me this error on the console, perhaps it is something very simple, but I can’t find a solution.

this is code Es_Extended

ESX.Game.GetPeds = function(onlyOtherPeds)
	local peds, myPed = {}, ESX.PlayerData.ped

	for ped in GetGamePool('CPed') do
		if ((onlyOtherPeds and ped ~= myPed) or not onlyOtherPeds) then
			table.insert(peds, ped)
		end
	end

	return peds
end

This is code taxi job

function GetRandomWalkingNPC()
	local search = {}
	local peds   = ESX.Game.GetPeds()

	for i=1, #peds, 1 do
		if IsPedHuman(peds[i]) and IsPedWalking(peds[i]) and not IsPedAPlayer(peds[i]) then
			table.insert(search, peds[i])
		end
	end
-- Taxi Job
Citizen.CreateThread(function()
	while true do

		Citizen.Wait(0)
		local playerPed = PlayerPedId()

		if OnJob then
			if CurrentCustomer == nil then
				DrawSub(_U('drive_search_pass'), 5000)

				if IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
					local waitUntil = GetGameTimer() + GetRandomIntInRange(30000, 45000)

					while OnJob and waitUntil > GetGameTimer() do
						Citizen.Wait(0)
					end

					if OnJob and IsPedInAnyVehicle(playerPed, false) and GetEntitySpeed(playerPed) > 0 then
						CurrentCustomer = GetRandomWalkingNPC()

						if CurrentCustomer ~= nil then
							CurrentCustomerBlip = AddBlipForEntity(CurrentCustomer)

							SetBlipAsFriendly(CurrentCustomerBlip, true)
							SetBlipColour(CurrentCustomerBlip, 2)
							SetBlipCategory(CurrentCustomerBlip, 3)
							SetBlipRoute(CurrentCustomerBlip, true)

							SetEntityAsMissionEntity(CurrentCustomer, true, false)
							ClearPedTasksImmediately(CurrentCustomer)
							SetBlockingOfNonTemporaryEvents(CurrentCustomer, true)

thanks for your help. :grinning:

Hey :slightly_smiling_face: !
Could you send the [polo_taxijob/client/main.lua] file ?

1 Like

Sure, here is the file, thank you!

I hope you can help me.

main.lua (26.3 KB)

Hum… I wasn’t seeing errors in the code, so I did some testing and didn’t get any error either ^^’ wich was a little unsetlling.

But, something caught my eye, in [es_extended/client/functions.lua] the implementation of the Esx.Game.GetPeds is a little different on my side (I use ESX 1.3 - Legacy)

ESX.Game.GetPeds = function(onlyOtherPeds)
	local peds, myPed, pool = {}, ESX.PlayerData.ped, GetGamePool('CPed')

	for i=1, #pool do
        if ((onlyOtherPeds and pool[i] ~= myPed) or not onlyOtherPeds) then
            table.insert(peds, pool[i])
        end
    end

	return peds
end

Even if the idea is the same, the structure used is a little different (when manipulating variables and functions). I’m curious, could you try to switch your es_extented function with this one and test things out ?

1 Like

Effectively, change the code and after doing tests, it works perfectly and does not give me any error in the F8 or in my console.

Now I have a question, if my version of ESX is different, do you recommend changing it to a more recent one? but i guess i should reconfigure it.

I also use Legacy, but I don’t remember where to look at my version.

And thank you very much for your help.

No probs :wink:

I would personnaly advise to stay as close as possible to the last release (for ESX or even resources), but I agree that it can rapidly become a pain in the ass to have to update the framework and other resources often ^^’
Have said that, I think as long as you are not using a very old deprecated version of ESX (like ESX 1.1 etc…) you should be fine. If you encounter an error like this in the future, that doesn’t seems to come from the actual resource code and pointing to [es_extended] you can take a look directly from the git repo if an update as been made to the file/function in question.

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