mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 16:01:36 +00:00
Fixed vehicle model mismatch error, closes #113
This commit is contained in:
+1
-1
@@ -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
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user