Implemented multiple vehicle spawn point system, closess #109

This commit is contained in:
ElPumpo
2018-10-20 20:06:47 +02:00
parent de674ab53a
commit 70a882165e
10 changed files with 68 additions and 67 deletions
+49 -54
View File
@@ -343,7 +343,6 @@ end
function OpenVehicleSpawnerMenu(station, partNum)
local vehicles = Config.PoliceStations[station].Vehicles
ESX.UI.Menu.CloseAll()
if Config.EnableSocietyOwnedVehicles then
@@ -353,7 +352,10 @@ function OpenVehicleSpawnerMenu(station, partNum)
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]})
table.insert(elements, {
label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']',
value = garageVehicles[i]
})
end
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
@@ -365,14 +367,16 @@ function OpenVehicleSpawnerMenu(station, partNum)
menu.close()
local vehicleProps = data.current.value
local foundSpawnPoint, spawnPoint = GetAvailableVehicleSpawnPoint(station, partNum)
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)
if foundSpawnPoint then
ESX.Game.SpawnVehicle(vehicleProps.model, spawnPoint, spawnPoint.heading, function(vehicle)
ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
TaskWarpPedIntoVehicle(PlayerPedId(), vehicle, -1)
end)
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
end
end, function(data, menu)
menu.close()
@@ -405,36 +409,29 @@ function OpenVehicleSpawnerMenu(station, partNum)
}, 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()
local foundSpawnPoint, spawnPoint = GetAvailableVehicleSpawnPoint(station, partNum)
if foundSpawnPoint then
if Config.MaxInService == -1 then
ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
ESX.Game.SpawnVehicle(data.current.model, spawnPoint, spawnPoint.heading, function(vehicle)
TaskWarpPedIntoVehicle(PlayerPedId(), 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)
if isInService then
ESX.Game.SpawnVehicle(data.current.model, spawnPoint, spawnPoint.heading, function(vehicle)
TaskWarpPedIntoVehicle(PlayerPedId(), 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)
@@ -448,11 +445,29 @@ function OpenVehicleSpawnerMenu(station, partNum)
end
end
function GetAvailableVehicleSpawnPoint(station, partNum)
local spawnPoints = Config.PoliceStations[station].Vehicles[partNum].SpawnPoints
local found, foundSpawnPoint = false, nil
for i=1, #spawnPoints, 1 do
if ESX.Game.IsSpawnPointClear(spawnPoints[i], spawnPoints[i].radius) then
found, foundSpawnPoint = true, spawnPoints[i]
break
end
end
if found then
return true, foundSpawnPoint
else
ESX.ShowNotification(_U('vehicle_blocked'))
return false
end
end
function OpenPoliceActionsMenu()
ESX.UI.Menu.CloseAll()
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'police_actions',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'police_actions',
{
title = 'Police',
align = 'top-left',
@@ -599,8 +614,7 @@ function OpenPoliceActionsMenu()
end, function(data2, menu2)
menu2.close()
end
)
end)
elseif data.current.value == 'object_spawner' then
ESX.UI.Menu.Open(
@@ -776,10 +790,10 @@ function OpenBodySearchMenu(player)
for i=1, #data.inventory, 1 do
if data.inventory[i].count > 0 then
table.insert(elements, {
label = _U('confiscate_inv', data.inventory[i].count, data.inventory[i].label),
value = data.inventory[i].name,
itemType = 'item_standard',
amount = data.inventory[i].count
label = _U('confiscate_inv', data.inventory[i].count, data.inventory[i].label),
value = data.inventory[i].name,
itemType = 'item_standard',
amount = data.inventory[i].count
})
end
end
@@ -916,14 +930,12 @@ function ShowPlayerLicense(player)
targetName = data.name
end
ESX.UI.Menu.Open(
'default', GetCurrentResourceName(), 'manage_license',
ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'manage_license',
{
title = _U('license_revoke'),
align = 'top-left',
elements = elements,
},
function(data, menu)
}, function(data, menu)
ESX.ShowNotification(_U('licence_you_revoked', data.current.label, targetName))
TriggerServerEvent('esx_policejob:message', GetPlayerServerId(player), _U('license_revoked', data.current.label))
@@ -932,17 +944,14 @@ function ShowPlayerLicense(player)
ESX.SetTimeout(300, function()
ShowPlayerLicense(player)
end)
end,
function(data, menu)
end, function(data, menu)
menu.close()
end
)
end)
end, GetPlayerServerId(player))
end
function OpenUnpaidBillsMenu(player)
local elements = {}
ESX.TriggerServerCallback('esx_billing:getTargetBills', function(bills)
@@ -1649,13 +1658,6 @@ Citizen.CreateThread(function()
currentPart = 'VehicleSpawner'
currentPartNum = i
end
if GetDistanceBetweenCoords(coords, v.Vehicles[i].SpawnPoint.x, v.Vehicles[i].SpawnPoint.y, v.Vehicles[i].SpawnPoint.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'VehicleSpawnPoint'
currentPartNum = i
end
end
for i=1, #v.Helicopters, 1 do
@@ -1665,13 +1667,6 @@ Citizen.CreateThread(function()
currentPart = 'HelicopterSpawner'
currentPartNum = i
end
if GetDistanceBetweenCoords(coords, v.Helicopters[i].SpawnPoint.x, v.Helicopters[i].SpawnPoint.y, v.Helicopters[i].SpawnPoint.z, true) < Config.MarkerSize.x then
isInMarker = true
currentStation = k
currentPart = 'HelicopterSpawnPoint'
currentPartNum = i
end
end
for i=1, #v.VehicleDeleters, 1 do
+11 -5
View File
@@ -57,15 +57,21 @@ Config.PoliceStations = {
Vehicles = {
{
Spawner = { x = 454.69, y = -1017.4, z = 27.430 },
SpawnPoint = { x = 438.42, y = -1018.3, z = 27.757 },
Heading = 90.0
Spawner = { x = 454.69, y = -1017.40, z = 27.43 },
SpawnPoints = {
{ x = 438.42, y = -1018.30, z = 27.75, heading = 90.0, radius = 6.0 },
{ x = 441.08, y = -1024.23, z = 28.30, heading = 90.0, radius = 6.0 },
{ x = 453.53, y = -1022.20, z = 28.02, heading = 90.0, radius = 6.0 },
{ x = 450.97, y = -1016.55, z = 28.10, heading = 90.0, radius = 6.0 }
}
},
{
Spawner = { x = 473.38, y = -1018.43, z = 27.00 },
SpawnPoint = { x = 475.98, y = -1021.65, z = 28.06 },
Heading = 276.11
SpawnPoints = {
{ x = 475.98, y = -1021.65, z = 28.06, heading = 276.11, radius = 6.0 },
{ x = 484.10, y = -1023.19, z = 27.57, heading = 302.54, radius = 6.0 }
}
}
},
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['br'] = {
['open_armory'] = 'Pressione ~INPUT_CONTEXT~ para acessar o arsenal',
-- Vehicles
['vehicle_menu'] = 'Veículo',
['vehicle_out'] = 'Já existe um carro fora da garagem',
['vehicle_blocked'] = 'Já existe um carro fora da garagem',
['vehicle_spawner'] = 'Pressione ~INPUT_CONTEXT~ para escolher um veículo',
['store_vehicle'] = 'Pressione ~INPUT_CONTEXT~ para guardar o veículo',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['de'] = {
['open_armory'] = 'Drücke ~INPUT_CONTEXT~ um die Waffenkammer zu öffnen',
-- Vehicles
['vehicle_menu'] = 'Fahrzeug',
['vehicle_out'] = 'es ist bereits ein Fahrzeug draussen',
['vehicle_blocked'] = 'es ist bereits ein Fahrzeug draussen',
['vehicle_spawner'] = 'Drücke ~INPUT_CONTEXT~ um ein Fahrzeug zu holen',
['store_vehicle'] = 'Drücke ~INPUT_CONTEXT~ um das Fahrzeug zu parken',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['en'] = {
['open_armory'] = 'press ~INPUT_CONTEXT~ to access the armory',
-- Vehicles
['vehicle_menu'] = 'vehicle',
['vehicle_out'] = 'there is already a car out of the garage',
['vehicle_blocked'] = 'all available spawn points are currently blocked!',
['vehicle_spawner'] = 'press ~INPUT_CONTEXT~ to take out a vehicle',
['store_vehicle'] = 'press ~INPUT_CONTEXT~ to store the vehicle',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['es'] = {
['open_armory'] = 'Presionarr ~INPUT_CONTEXT~ para acceder a la armeria',
-- Vehicles
['vehicle_menu'] = 'Vehículo',
['vehicle_out'] = 'Ya tienes un vehículo fuera',
['vehicle_blocked'] = 'Ya tienes un vehículo fuera',
['vehicle_spawner'] = 'Presionar ~INPUT_CONTEXT~ para sacar un vehículo',
['store_vehicle'] = 'Presionar ~INPUT_CONTEXT~ para guardar un vehículo',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['fi'] = {
['open_armory'] = 'paina ~INPUT_CONTEXT~ avataksesi asevarasto',
-- Vehicles
['vehicle_menu'] = 'ajoneuvo',
['vehicle_out'] = 'ajoneuvo on jo ulkona tallista',
['vehicle_blocked'] = 'ajoneuvo on jo ulkona tallista',
['vehicle_spawner'] = 'paina ~INPUT_CONTEXT~ ottaaksesi auton ulos',
['store_vehicle'] = 'paina ~INPUT_CONTEXT~ laittaaksesi auto talliin',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['fr'] = {
['open_armory'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder à l\'armurerie',
-- Vehicles
['vehicle_menu'] = 'véhicule',
['vehicle_out'] = 'il y a déja un véhicule de sorti',
['vehicle_blocked'] = 'il y a déja un véhicule de sorti',
['vehicle_spawner'] = 'appuyez sur ~INPUT_CONTEXT~ pour sortir un véhicule',
['store_vehicle'] = 'appuyez sur ~INPUT_CONTEXT~ pour ranger le véhicule',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['pl'] = {
['open_armory'] = 'naciśnij ~INPUT_CONTEXT~ żeby uzyskać dostęp do zbrojowni',
-- Vehicles
['vehicle_menu'] = 'pojazdy',
['vehicle_out'] = 'masz już pojazd poza garażem',
['vehicle_blocked'] = 'masz już pojazd poza garażem',
['vehicle_spawner'] = 'naciśnij ~INPUT_CONTEXT~ żeby wziąć pojazd',
['store_vehicle'] = 'naciśnij ~INPUT_CONTEXT~ żeby przechować pojazd',
-- Service
+1 -1
View File
@@ -17,7 +17,7 @@ Locales['sv'] = {
['open_armory'] = 'tryck ~INPUT_CONTEXT~ för att komma åt förrådet',
-- Vehicles
['vehicle_menu'] = 'bilar',
['vehicle_out'] = 'det finns redan en bil ute!',
['vehicle_blocked'] = 'alla tillgänliga spawn points är blockerade!',
['vehicle_spawner'] = 'tryck ~INPUT_CONTEXT~ för att ta ut en bil',
['store_vehicle'] = 'tryck ~INPUT_CONTEXT~ för att parkera bilen',
-- Service