Add vehicle
ในตัวอย่างนี้จะใช้ esx_vehicleshop และ esx_policejob เป็นตัวอย่าง
esx_vehicleshop
ESX.RegisterServerCallback('esx_vehicleshop:buyVehicle', function(source, cb, model, plate)
local xPlayer = ESX.GetPlayerFromId(source)
local modelPrice = getVehicleFromModel(model).price
if modelPrice and xPlayer.getMoney() >= modelPrice then
xPlayer.removeMoney(modelPrice, "Vehicle Purchase")
MySQL.insert('INSERT INTO owned_vehicles (owner, plate, vehicle) VALUES (?, ?, ?)', {xPlayer.identifier, plate, json.encode({model = joaat(model), plate = plate})
}, 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)
Wait(100)
local vehicle = NetworkGetEntityFromNetworkId(vehicle)
Wait(300)
TaskWarpPedIntoVehicle(GetPlayerPed(source), vehicle, -1)
exports['zobyeteam_garage']:addVehicle(source, xPlayer.identifier, plate, {model = model, plate = plate})
end)
cb(true)
end)
else
cb(false)
end
end)และตัวอย่างสำหรับ esx_policejob
Last updated