How do I find this error

I’ve been happily coding away on esx_jobs and then text stopped showing up above my esx_jobs vehicle return point when testing. I’ve undone my code up to before it started failing but I’m still getting this error. Given it’s in the Client console and goes off screen and you can’t selecet and scroll in that panel, how can I find out what the error is?

32ca01c3 native is AddTextEntry - Natives @ Cfx.re Docs

Find it in your script, and check what’s wrong with it. You’re probably passing nil variables in it

I’ve not even done anything that drills down to an AddTextEntry call, uggh. I’ll keep digging, thanks

Well…the error comes from “es_extended”, not esx_jobs. So it most likely is linked to a function that goes into es_extended, and calls a text entry there.

What I’d like to know thouhg is which line that’s throwing the error which is probably on the end of the red text. Is there a way I can see it given the panel doesn’t scroll? log somewhere?

This is driving me crazy. I undid everything and it went away and I started piecing the code back together. There’s two components to achieve what I’m doing. I am making job vehicles lockable, but I need to modify esx_jobs and esx_vehiclelock.

esx_vehiclelock:
I change the server callback to make call a new export I added on esx_jobs

ESX.RegisterServerCallback('esx_vehiclelock:requestPlayerCars', function(source, cb, plate)
	local xPlayer = ESX.GetPlayerFromId(source)
	local vehicleOwned = nil

	MySQL.Async.fetchAll('SELECT 1 FROM owned_vehicles WHERE owner = @owner AND plate = @plate', {
		['@owner'] = xPlayer.identifier,
		['@plate'] = plate
	}, function(result)
		vehicleOwned = result[1] ~= nil
	end)

	if not vehicleOwned then
		vehicleOwned = exports.esx_jobs:IsJobVehicleInUseBy(plate, xPlayer.identifier)
	end

	cb(vehicleOwned)
end)

This works geat, I can now lock my own vehicles and job vehicles when they spawn.

esx_jobs:
I’m maintaining a list of assigned vehicle plates like so. Note that I moved the plate allocation into the server so that I get unique plates between all players on the server.

function trim(s)
	return (string.gsub(s, "^%s*(.-)%s*$", "%1"))
end

local playerJobVehicles = {}

ESX.RegisterServerCallback('esx_jobs:allocateJobVehiclePlate', function(source, cb, identifier)
	local plate = 'WORK' .. math.random(100, 900)
	while playerJobVehicles[trim(plate)] ~= nil do
		Citizen.Wait(0)
		plate = 'WORK' .. math.random(100, 900)
	end

	playerJobVehicles[plate] = identifier

	cb(plate)
end)

RegisterNetEvent('esx_jobs:deallocateJobVehiclePlate')
AddEventHandler('esx_jobs:deallocateJobVehiclePlate', function(plate)
	playerJobVehicles[trim(plate)] = nil
end)

function IsJobVehicleInUseBy(plate, identifier)
	local inUse = nil
	local inUseBy = playerJobVehicles[trim(plate)]
	if inUseBy ~= nil and inUseBy == identifier then
		inUse = 1
	end

	return inUse
end
exports('IsJobVehicleInUseBy', IsJobVehicleInUseBy)

From the client I have to trigger this callback so the rest of the code after the vehicle spawn gets pushed into the callback function:

RegisterNetEvent('esx_jobs:spawnJobVehicle')
AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
	local playerPed = PlayerPedId()

	ESX.Game.SpawnVehicle(vehicle.Hash, spawnPoint.Pos, spawnPoint.Heading, function(spawnedVehicle)

		if vehicle.Trailer ~= "none" then
			ESX.Game.SpawnVehicle(vehicle.Trailer, spawnPoint.Pos, spawnPoint.Heading, function(trailer)
				AttachVehicleToTrailer(spawnedVehicle, trailer, 1.1)
			end)
		end

		-- save & set plate <<<<<<<< New Server Callback for plate allocation here >>>>>>>>
		ESX.TriggerServerCallback('esx_jobs:allocateJobVehiclePlate', function(plate)
			SetVehicleNumberPlateText(spawnedVehicle, plate)
			table.insert(myPlate, plate)
			plate = string.gsub(plate, " ", "")

			TaskWarpPedIntoVehicle(playerPed, spawnedVehicle, -1)

			if vehicle.HasCaution then
				vehicleInCaseofDrop = spawnedVehicle
				vehicleObjInCaseofDrop = vehicle
				vehicleMaxHealth = GetVehicleEngineHealth(spawnedVehicle)
			end
		end, PlayerData.identifier)
	end)
end)

To remove the plate allocation when players return the vehicle:

After spawning vehicles a few seconds later when driving the error shows up:


I’m finding now it’s only happening if I spawn multiple vehicles via the esx_jobs spawn point, but only on the third vehicle. If I drive to the sespawn point the circle is on the ground but Inever get the message to press e to put away.

Hey man did you fix this?

Sorry, all this time on I have no idea. Frankly I can’t stand ESX so not that keen to get back into it. I’ve also not been that involved with FiveM coding. Maybe ask the question to the main forum and see if someone has an answer.

Okay man