Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion [esx_addons]/esx_vehicleshop/client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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()
Expand Down
9 changes: 5 additions & 4 deletions [esx_addons]/esx_vehicleshop/server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Loading