Hello, to explain my problem is that currently in the main.lua client esx_policejob the police vehicles must be bought to use them during the service but what I’m trying to do is make sure that we can stow the vehicle and take it out but remove the police vehicle shop and put in the place what had before in the old version of esx_policejob that is to say to be able to take any vehicle in relation to his grade obviously.
If anyone would have an idea how to do it would be cool because it’s been 2 weeks since I was there and still can not do it.
function OpenVehicleSpawnerMenu(type, station, part, partNum)
local playerCoords = GetEntityCoords(PlayerPedId())
PlayerData = ESX.GetPlayerData()
local elements = {
{label = _U(‘garage_storeditem’), action = ‘garage’},
{label = _U(‘garage_storeitem’), action = ‘store_garage’},
{label = _U(‘garage_police’), action = ‘police_garage’}
}
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle', {
title = _U('garage_title'),
align = 'top-left',
elements = elements
}, function(data, menu)
if data.current.action == 'buy_vehicle' then
local shopElements, shopCoords = {}
OpenShopMenu(shopElements, playerCoords, shopCoords)
elseif data.current.action == 'garage' then
local garage = {}
ESX.TriggerServerCallback('esx_vehicleshop:retrieveJobVehicles', function(jobVehicles)
if #jobVehicles > 0 then
for k,v in ipairs(jobVehicles) do
local props = json.decode(v.vehicle)
local vehicleName = GetLabelText(GetDisplayNameFromVehicleModel(props.model))
local label = ('%s - <span style="color:darkgoldenrod;">%s</span>: '):format(vehicleName, props.plate)
if v.stored then
label = label .. ('<span style="color:green;">%s</span>'):format(_U('garage_stored'))
else
label = label .. ('<span style="color:darkred;">%s</span>'):format(_U('garage_notstored'))
end
table.insert(garage, {
label = label,
stored = v.stored,
model = props.model,
vehicleProps = props
})
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_garage', {
title = _U('garage_title'),
align = 'top-left',
elements = garage
}, function(data2, menu2)
if data2.current.stored then
local foundSpawn, spawnPoint = GetAvailableVehicleSpawnPoint(station, part, partNum)
if foundSpawn then
menu2.close()
ESX.Game.SpawnVehicle(data2.current.model, spawnPoint.coords, spawnPoint.heading, function(vehicle)
ESX.Game.SetVehicleProperties(vehicle, data2.current.vehicleProps)
TriggerServerEvent('esx_vehicleshop:setJobVehicleState', data2.current.vehicleProps.plate, false)
ESX.ShowNotification(_U('garage_released'))
end)
end
else
ESX.ShowNotification(_U('garage_notavailable'))
end
end, function(data2, menu2)
menu2.close()
end)
if Config.EnableSocietyOwnedVehicles then
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
{
title = _U('garage_title'),
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
else
ESX.ShowNotification(_U('garage_empty'))
end
end, type)
elseif data.current.action == 'store_garage' then
StoreNearbyVehicle(playerCoords)
end
end, function(data, menu)
menu.close()
end)
end