Resell vehicle

So hi, im making a script so players come down to my custom dealership(and mechanic) so they go to a marker next to the store and then they sell there vehicle and the dealership gets the vehicle (so they can sell it again) and the player gets the money (from the society of the dealership) but i can not get it to work

here is my data base:

and here is the server script:

ESX.RegisterServerCallback('esx_amigos:resellVehicle', function (source, cb, plate, model)
	local resellPrice = 0

	-- calculate the resell price
	for i=1, #Vehicles, 1 do
		if GetHashKey(Vehicles[i].model) == model then
			resellPrice = ESX.Math.Round(Vehicles[i].price / 100 * Config.ResellPercentage)
			break
		end
	end

	if resellPrice == 0 then
		print(('esx_amigos: %s attempted to sell an unknown vehicle!'):format(GetPlayerIdentifiers(source)[1]))
		cb(false)
	end

	MySQL.Async.fetchAll('SELECT * FROM rented_vehicles WHERE plate = @plate', {
		['@plate'] = plate
	}, function (result)
		if result[1] then -- is it a rented vehicle?
			cb(false) -- it is, don't let the player sell it since he doesn't own it
		else
			local xPlayer = ESX.GetPlayerFromId(source)
			local vehicle   = result[1].vehicle
			local basePrice = result[1].base_price

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

				if result[1] then -- does the owner match?

					local vehicle = json.decode(result[1].vehicle)

					if vehicle.model == model then
						if vehicle.plate == plate then
							if account.money >= resellPrice then
								account.removeMoney(resellPrice)

								MySQL.Async.execute('INSERT INTO amigos_vehicles (vehicle, price) VALUES (@vehicle, @price)',
								{
									['@vehicle'] = vehicle,
									['@price']   = nil
								})

								MySQL.Async.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
									['@plate'] = plate
								})

							cb(true)
						else
							print(('esx_amigos: %s attempted to sell an vehicle with plate mismatch!'):format(xPlayer.identifier))
							cb(false)
						end
					else
						print(('esx_amigos: %s attempted to sell an vehicle with model mismatch!'):format(xPlayer.identifier))
						cb(false)
					end

				else

					if xPlayer.job.grade_name == 'boss' then
						MySQL.Async.fetchAll('SELECT * FROM owned_vehicles WHERE owner = @owner AND @plate = plate', {
							['@owner'] = 'society:' .. xPlayer.job.name,
							['@plate'] = plate
						}, function (result)

							if result[1] then

								local vehicle = json.decode(result[1].vehicle)

								if vehicle.model == model then
									if vehicle.plate == plate then

										TriggerEvent('esx_addonaccount:getSharedAccount', 'society_' .. society, function (account)
										if account.money >= resellPrice then
											account.removeMoney(resellPrice)

											MySQL.Async.execute('INSERT INTO amigos_vehicles (vehicle, price) VALUES (@vehicle, @price)',
											{
												['@vehicle'] = vehicle,
												['@price']   = nil
											})

											MySQL.Async.execute('DELETE FROM owned_vehicles WHERE plate = @plate', {
												['@plate'] = plate
											})

										cb(true)

									else
										print(('esx_amigos: %s attempted to sell an vehicle with plate mismatch!'):format(xPlayer.identifier))
										cb(false)
									end
								    end)
								else
									print(('esx_amigos: %s attempted to sell an vehicle with model mismatch!'):format(xPlayer.identifier))
									cb(false)
								end

							else
								cb(false)
							end
						 end

						end)
					else
						cb(false)
					end
				end
                end
			end)
		end
	end)
end)

error message:

Whats on line 880 of client/main.lua? That’s where you should be looking. It might be a value that you are passing from server side (elsewhere because you don’t have a TriggerClientEvent in the posted code) that is actually nil a.k.a. doesn’t exist/has no value

Ill post that later on if i didnt figure it out yet
Wanna add me on discord lenzh#3680

so on line 880 of client lua i have this script i marked line 880

	elseif zone == 'ResellVehicle' then

		local playerPed = PlayerPedId()

		if IsPedSittingInAnyVehicle(playerPed) then

			local vehicle     = GetVehiclePedIsIn(playerPed, false)
			local vehicleData, model, resellPrice, plate

			if GetPedInVehicleSeat(vehicle, -1) == playerPed then
				for i=1, #Vehicles, 1 do
					if GetHashKey(Vehicles[i].model) == GetEntityModel(vehicle) then
						vehicleData = Vehicles[i]
						break
					end
				end

--[[line 880--]]				resellPrice = ESX.Math.Round(vehicleData.price / 100 * Config.ResellPercentage)
				model = GetEntityModel(vehicle)
				plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle))

				CurrentAction     = 'resell_vehicle'
				CurrentActionMsg  = _U('sell_menu', vehicleData.name, ESX.Math.GroupDigits(resellPrice))

				CurrentActionData = {
					vehicle = vehicle,
					label = vehicleData.name,
					price = resellPrice,
					model = model,
					plate = plate
				}
			end

		end

okk, so either vehicleData.price or Config.ResellPercentage are nil. Just do some digging yourself. Can’t do any :two_men_holding_hands:

Tried to figure it out but i think im blind :joy:

Any help?

I went to have a look but no succes

When I give to sell a vehicle, I get this error:

This isn’t a release.