From f510277ba0b2191d10a3e707b5391d19474116a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Pedro=20Correia?= Date: Mon, 16 Nov 2020 19:05:34 +0000 Subject: [PATCH] Nill value when vehicle is missing on vehicle list Fixed error "attempt to index a nil value (local 'firstVehicleData')" when vehicle doesn't exist on vehicle list/database. --- client/main.lua | 26 ++++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/client/main.lua b/client/main.lua index 28b00811..2b0816f6 100644 --- a/client/main.lua +++ b/client/main.lua @@ -705,20 +705,22 @@ AddEventHandler('esx_vehicleshop:hasEnteredMarker', function(zone) end end - resellPrice = ESX.Math.Round(vehicleData.price / 100 * Config.ResellPercentage) - model = GetEntityModel(vehicle) - plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)) + if vehicleData then + 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)) + 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 - } + CurrentActionData = { + vehicle = vehicle, + label = vehicleData.name, + price = resellPrice, + model = model, + plate = plate + } + end end end