diff --git a/[esx_addons]/esx_vehicleshop/client/main.lua b/[esx_addons]/esx_vehicleshop/client/main.lua index 450a91e5..97c7cf2d 100644 --- a/[esx_addons]/esx_vehicleshop/client/main.lua +++ b/[esx_addons]/esx_vehicleshop/client/main.lua @@ -205,6 +205,8 @@ function OpenShopMenu() end, vehicleData.model) else local generatedPlate = GeneratePlate() + local vehicleProps = ESX.Game.GetVehicleProperties(currentDisplayVehicle) + vehicleProps.plate = generatedPlate ESX.TriggerServerCallback('esx_vehicleshop:buyVehicle', function(success) if success then @@ -217,7 +219,7 @@ function OpenShopMenu() else ESX.ShowNotification(TranslateCap('not_enough_money')) end - end, vehicleData.model, generatedPlate) + end, vehicleData.model, vehicleProps) end else menu2.close() diff --git a/[esx_addons]/esx_vehicleshop/server/main.lua b/[esx_addons]/esx_vehicleshop/server/main.lua index 7ed853a0..e4f20d6e 100644 --- a/[esx_addons]/esx_vehicleshop/server/main.lua +++ b/[esx_addons]/esx_vehicleshop/server/main.lua @@ -149,17 +149,18 @@ AddEventHandler('esx_vehicleshop:putStockItems', function(itemName, count) end) end) -ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function(source, cb, model, plate) +ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function(source, cb, model, props) local xPlayer = ESX.Player(source) local modelPrice = getVehicleFromModel(model).price if modelPrice and xPlayer.getMoney() >= modelPrice then + props.model = model xPlayer.removeMoney(modelPrice, "Vehicle Purchase") - MySQL.insert('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (?, ?, ?)', {xPlayer.getIdentifier(), plate, json.encode({model = joaat(model), plate = plate}) + MySQL.insert('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (?, ?, ?)', {xPlayer.getIdentifier(), props.plate, json.encode(props) }, function(rowsChanged) - xPlayer.showNotification(TranslateCap('vehicle_belongs', plate)) - ESX.OneSync.SpawnVehicle(joaat(model), Config.Zones.ShopOutside.Pos, Config.Zones.ShopOutside.Heading,{plate = plate}, function(vehicle) + xPlayer.showNotification(TranslateCap('vehicle_belongs', props.plate)) + ESX.OneSync.SpawnVehicle(joaat(model), Config.Zones.ShopOutside.Pos, Config.Zones.ShopOutside.Heading, props, function(vehicle) Wait(100) local vehicle = NetworkGetEntityFromNetworkId(vehicle) Wait(300)