Fixed vehicle model mismatch error, closes #113

This commit is contained in:
ElPumpo
2018-12-08 15:43:03 +01:00
parent 5cf117f274
commit f79f8df02e
2 changed files with 9 additions and 4 deletions
+1 -1
View File
@@ -871,7 +871,7 @@ AddEventHandler('esx_vehicleshop:hasEnteredMarker', function (zone)
end
resellPrice = ESX.Math.Round(vehicleData.price / 100 * Config.ResellPercentage)
model = string.lower(GetDisplayNameFromVehicleModel(GetEntityModel(vehicle)))
model = GetEntityModel(vehicle)
plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle))
CurrentAction = 'resell_vehicle'
+8 -3
View File
@@ -342,16 +342,21 @@ ESX.RegisterServerCallback('esx_vehicleshop:giveBackVehicle', function (source,
end)
ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function (source, cb, plate, model)
local resellPrice
local resellPrice = 0
-- calculate the resell price
for i=1, #Vehicles, 1 do
if Vehicles[i].model == model then
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_vehicleshop: %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)
@@ -369,7 +374,7 @@ ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function (source, cb
local vehicle = json.decode(result[1].vehicle)
if vehicle.model == GetHashKey(model) then
if vehicle.model == model then
if vehicle.plate == plate then
xPlayer.addMoney(resellPrice)
RemoveOwnedVehicle(plate)