Untitled diff
0 removals
107 lines
11 additions
118 lines
function AddVehicleKeys(vehicle)
local localVehPlateTest = GetVehicleNumberPlateText(vehicle)
if localVehPlateTest ~= nil then
local localVehPlate = string.lower(localVehPlateTest)
TriggerEvent('ls:newVehicle', localVehPlate, nil, nil)
end
end
function OpenVehicleSpawnerMenu(station, partNum)
function OpenVehicleSpawnerMenu(station, partNum)
local vehicles = Config.PoliceStations[station].Vehicles
local vehicles = Config.PoliceStations[station].Vehicles
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.CloseAll()
if Config.EnableSocietyOwnedVehicles then
if Config.EnableSocietyOwnedVehicles then
local elements = {}
local elements = {}
ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(garageVehicles)
ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(garageVehicles)
for i=1, #garageVehicles, 1 do
for i=1, #garageVehicles, 1 do
table.insert(elements, {label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']', value = garageVehicles[i]})
table.insert(elements, {label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']', value = garageVehicles[i]})
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
{
{
title = _U('vehicle_menu'),
title = _U('vehicle_menu'),
align = 'top-left',
align = 'top-left',
elements = elements
elements = elements
}, function(data, menu)
}, function(data, menu)
menu.close()
menu.close()
local vehicleProps = data.current.value
local vehicleProps = data.current.value
ESX.Game.SpawnVehicle(vehicleProps.model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
ESX.Game.SpawnVehicle(vehicleProps.model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
local playerPed = PlayerPedId()
local playerPed = PlayerPedId()
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
AddVehicleKeys(vehicle)
end)
end)
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
end, function(data, menu)
end, function(data, menu)
menu.close()
menu.close()
CurrentAction = 'menu_vehicle_spawner'
CurrentAction = 'menu_vehicle_spawner'
CurrentActionMsg = _U('vehicle_spawner')
CurrentActionMsg = _U('vehicle_spawner')
CurrentActionData = {station = station, partNum = partNum}
CurrentActionData = {station = station, partNum = partNum}
end)
end)
end, 'police')
end, 'police')
else
else
local elements = {}
local elements = {}
local sharedVehicles = Config.AuthorizedVehicles.Shared
local sharedVehicles = Config.AuthorizedVehicles.Shared
for i=1, #sharedVehicles, 1 do
for i=1, #sharedVehicles, 1 do
table.insert(elements, { label = sharedVehicles[i].label, model = sharedVehicles[i].model})
table.insert(elements, { label = sharedVehicles[i].label, model = sharedVehicles[i].model})
end
end
local authorizedVehicles = Config.AuthorizedVehicles[PlayerData.job.grade_name]
local authorizedVehicles = Config.AuthorizedVehicles[PlayerData.job.grade_name]
for i=1, #authorizedVehicles, 1 do
for i=1, #authorizedVehicles, 1 do
table.insert(elements, { label = authorizedVehicles[i].label, model = authorizedVehicles[i].model})
table.insert(elements, { label = authorizedVehicles[i].label, model = authorizedVehicles[i].model})
end
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
{
{
title = _U('vehicle_menu'),
title = _U('vehicle_menu'),
align = 'top-left',
align = 'top-left',
elements = elements
elements = elements
}, function(data, menu)
}, function(data, menu)
menu.close()
menu.close()
local model = data.current.model
local model = data.current.model
local vehicle = GetClosestVehicle(vehicles[partNum].SpawnPoint.x, vehicles[partNum].SpawnPoint.y, vehicles[partNum].SpawnPoint.z, 3.0, 0, 71)
local vehicle = GetClosestVehicle(vehicles[partNum].SpawnPoint.x, vehicles[partNum].SpawnPoint.y, vehicles[partNum].SpawnPoint.z, 3.0, 0, 71)
if not DoesEntityExist(vehicle) then
if not DoesEntityExist(vehicle) then
local playerPed = PlayerPedId()
local playerPed = PlayerPedId()
if Config.MaxInService == -1 then
if Config.MaxInService == -1 then
ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
SetVehicleMaxMods(vehicle)
SetVehicleMaxMods(vehicle)
AddVehicleKeys(vehicle)
end)
end)
else
else
ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
if isInService then
if isInService then
ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
SetVehicleMaxMods(vehicle)
SetVehicleMaxMods(vehicle)
AddVehicleKeys(vehicle)
end)
end)
else
else
ESX.ShowNotification(_U('service_not'))
ESX.ShowNotification(_U('service_not'))
end
end
end, 'police')
end, 'police')
end
end
else
else
ESX.ShowNotification(_U('vehicle_out'))
ESX.ShowNotification(_U('vehicle_out'))
end
end
end, function(data, menu)
end, function(data, menu)
menu.close()
menu.close()
CurrentAction = 'menu_vehicle_spawner'
CurrentAction = 'menu_vehicle_spawner'
CurrentActionMsg = _U('vehicle_spawner')
CurrentActionMsg = _U('vehicle_spawner')
CurrentActionData = {station = station, partNum = partNum}
CurrentActionData = {station = station, partNum = partNum}
end)
end)
end
end
end
end