Advertisement
Guest User

Untitled

a guest
Aug 28th, 2018
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.16 KB | None | 0 0
  1. function ListVehiclesMenu()
  2.     local elements = {}
  3.  
  4.     ESX.TriggerServerCallback('eden_garage:getVehicles',
  5.     function(vehicles)
  6.  
  7.         for _,v in pairs(vehicles) do
  8.             local comment = v.comment
  9.             local hashVehicule = v.vehicle.model
  10.             local vehicleName = GetDisplayNameFromVehicleModel(hashVehicule)
  11.             local labelvehicle
  12.             local plate = v.plate
  13.  
  14.             if(v.state)then
  15.             labelvehicle = comment.. ' |' .. vehicleName.. ' [' .. plate .. '] ' .._U('garage')
  16.             else
  17.             labelvehicle = comment.. ' |' .. vehicleName.. ' [' .. plate .. '] ' .._U('municipal_pound')
  18.             end
  19.             table.insert(elements, {label =labelvehicle , value = v})
  20.            
  21.         end
  22.         local c = 0
  23.         for _,a in pairs(vehicles) do
  24.             if (a.state) then
  25.                 c = c + 1
  26.             else
  27.                 c = c - 1
  28.             end
  29.            
  30.         end
  31.  
  32.         ESX.UI.Menu.Open(
  33.             'default', GetCurrentResourceName(), 'spawn_vehicle',
  34.             {
  35.                 title    = _U('garage'),
  36.                 align    = 'top-left',
  37.                 elements = elements,
  38.             },
  39.             function(data, menu)
  40.                 if(data.current.value.state)then
  41.                     if c > 0 then
  42.                        
  43.                         menu.close()
  44.                    
  45.                             ESX.UI.Menu.CloseAll()
  46.                             local elements = {
  47.                                 {label = _U('spawn_the_vehicle'), value = 'yes'},
  48.                                 {label = _U('add_comment'), value = 'no'},
  49.                             }
  50.                             ESX.UI.Menu.Open(
  51.                                 'default', GetCurrentResourceName(), 'delete_menu',
  52.                                 {
  53.                                     title    = ('Car options'.. ' | ' .. data.current.value.plate),
  54.                                     align    = 'center',
  55.                                     elements = elements,
  56.                                 },
  57.                                     function(data, menu, vehicles)
  58.                        
  59.                                         menu.close()
  60.                                         if(data.current.value == 'yes') then
  61.                                             SpawnVehicle(data.current.value.vehicle, data.current.value.plate)
  62.                                         end
  63.                                         if(data.current.value == 'no') then
  64.                                             ESX.ShowNotification(_U('visit_mechanic'))
  65.                                         end
  66.                                 end,
  67.                             function(data, menu)
  68.                                 menu.close()       
  69.                             end
  70.                             )                      
  71.                    
  72.                         else
  73.                         TriggerEvent('esx:showNotification', _U('vehicle_is_impounded'))
  74.                         end
  75.                     end --if
  76.             end, -- end of function :211
  77.             function(data, menu)
  78.                 menu.close()
  79.                 --CurrentAction = 'open_garage_action'
  80.             end
  81.         )  
  82.     end)
  83. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement