Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function OpenVehicleSpawnerMenu(station, partNum)
- local vehicles = Config.PoliceStations[station].Vehicles
- ESX.UI.Menu.CloseAll()
- if Config.EnableSocietyOwnedVehicles then
- local elements = {}
- ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(garageVehicles)
- for i=1, #garageVehicles, 1 do
- table.insert(elements, {label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']', value = garageVehicles[i]})
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
- {
- title = _U('vehicle_menu'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- menu.close()
- local vehicleProps = data.current.value
- ESX.Game.SpawnVehicle(vehicleProps.model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
- ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
- local playerPed = PlayerPedId()
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- end)
- TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
- end, function(data, menu)
- menu.close()
- CurrentAction = 'menu_vehicle_spawner'
- CurrentActionMsg = _U('vehicle_spawner')
- CurrentActionData = {station = station, partNum = partNum}
- end)
- end, 'police')
- else
- local elements = {}
- local sharedVehicles = Config.AuthorizedVehicles.Shared
- for i=1, #sharedVehicles, 1 do
- table.insert(elements, { label = sharedVehicles[i].label, model = sharedVehicles[i].model})
- end
- local authorizedVehicles = Config.AuthorizedVehicles[PlayerData.job.grade_name]
- for i=1, #authorizedVehicles, 1 do
- table.insert(elements, { label = authorizedVehicles[i].label, model = authorizedVehicles[i].model})
- end
- ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
- {
- title = _U('vehicle_menu'),
- align = 'top-left',
- elements = elements
- }, function(data, menu)
- menu.close()
- local model = data.current.model
- local vehicle = GetClosestVehicle(vehicles[partNum].SpawnPoint.x, vehicles[partNum].SpawnPoint.y, vehicles[partNum].SpawnPoint.z, 3.0, 0, 71)
- if not DoesEntityExist(vehicle) then
- local playerPed = PlayerPedId()
- if Config.MaxInService == -1 then
- ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- SetVehicleMaxMods(vehicle)
- end)
- else
- ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
- if isInService then
- ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
- TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
- SetVehicleMaxMods(vehicle)
- end)
- else
- ESX.ShowNotification(_U('service_not'))
- end
- end, 'police')
- end
- else
- ESX.ShowNotification(_U('vehicle_out'))
- end
- end, function(data, menu)
- menu.close()
- CurrentAction = 'menu_vehicle_spawner'
- CurrentActionMsg = _U('vehicle_spawner')
- CurrentActionData = {station = station, partNum = partNum}
- end)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement