Advertisement
Guest User

Untitled

a guest
Aug 18th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. function OpenVehicleSpawnerMenu(station, partNum)
  2.  
  3. local vehicles = Config.PoliceStations[station].Vehicles
  4. ESX.UI.Menu.CloseAll()
  5.  
  6. if Config.EnableSocietyOwnedVehicles then
  7.  
  8. local elements = {}
  9.  
  10. ESX.TriggerServerCallback('esx_society:getVehiclesInGarage', function(garageVehicles)
  11.  
  12. for i=1, #garageVehicles, 1 do
  13. table.insert(elements, {label = GetDisplayNameFromVehicleModel(garageVehicles[i].model) .. ' [' .. garageVehicles[i].plate .. ']', value = garageVehicles[i]})
  14. end
  15.  
  16. ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
  17. {
  18. title = _U('vehicle_menu'),
  19. align = 'top-left',
  20. elements = elements
  21. }, function(data, menu)
  22. menu.close()
  23.  
  24. local vehicleProps = data.current.value
  25.  
  26. ESX.Game.SpawnVehicle(vehicleProps.model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
  27. ESX.Game.SetVehicleProperties(vehicle, vehicleProps)
  28. local playerPed = PlayerPedId()
  29. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  30. end)
  31.  
  32. TriggerServerEvent('esx_society:removeVehicleFromGarage', 'police', vehicleProps)
  33. end, function(data, menu)
  34. menu.close()
  35.  
  36. CurrentAction = 'menu_vehicle_spawner'
  37. CurrentActionMsg = _U('vehicle_spawner')
  38. CurrentActionData = {station = station, partNum = partNum}
  39. end)
  40.  
  41. end, 'police')
  42.  
  43. else
  44.  
  45. local elements = {}
  46.  
  47. local sharedVehicles = Config.AuthorizedVehicles.Shared
  48. for i=1, #sharedVehicles, 1 do
  49. table.insert(elements, { label = sharedVehicles[i].label, model = sharedVehicles[i].model})
  50. end
  51.  
  52. local authorizedVehicles = Config.AuthorizedVehicles[PlayerData.job.grade_name]
  53. for i=1, #authorizedVehicles, 1 do
  54. table.insert(elements, { label = authorizedVehicles[i].label, model = authorizedVehicles[i].model})
  55. end
  56.  
  57. ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_spawner',
  58. {
  59. title = _U('vehicle_menu'),
  60. align = 'top-left',
  61. elements = elements
  62. }, function(data, menu)
  63. menu.close()
  64.  
  65. local model = data.current.model
  66. local vehicle = GetClosestVehicle(vehicles[partNum].SpawnPoint.x, vehicles[partNum].SpawnPoint.y, vehicles[partNum].SpawnPoint.z, 3.0, 0, 71)
  67.  
  68. if not DoesEntityExist(vehicle) then
  69.  
  70. local playerPed = PlayerPedId()
  71.  
  72. if Config.MaxInService == -1 then
  73.  
  74. ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
  75. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  76. SetVehicleMaxMods(vehicle)
  77. end)
  78. else
  79.  
  80. ESX.TriggerServerCallback('esx_service:isInService', function(isInService)
  81. if isInService then
  82.  
  83. ESX.Game.SpawnVehicle(model, vehicles[partNum].SpawnPoint, vehicles[partNum].Heading, function(vehicle)
  84. TaskWarpPedIntoVehicle(playerPed, vehicle, -1)
  85. SetVehicleMaxMods(vehicle)
  86. end)
  87. else
  88. ESX.ShowNotification(_U('service_not'))
  89. end
  90. end, 'police')
  91. end
  92.  
  93. else
  94. ESX.ShowNotification(_U('vehicle_out'))
  95. end
  96.  
  97. end, function(data, menu)
  98. menu.close()
  99.  
  100. CurrentAction = 'menu_vehicle_spawner'
  101. CurrentActionMsg = _U('vehicle_spawner')
  102. CurrentActionData = {station = station, partNum = partNum}
  103.  
  104. end)
  105.  
  106. end
  107. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement