Advertisement
Guest User

Client.lua

a guest
Jul 17th, 2019
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 45.52 KB | None | 0 0
  1. Keys = {
  2.     ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57,
  3.     ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177,
  4.     ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18,
  5.     ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182,
  6.     ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81,
  7.     ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70,
  8.     ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178,
  9.     ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173,
  10.     ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
  11. }
  12.  
  13. ESX = nil
  14.  
  15. local PlayerData              = {}
  16. local JobBlips                = {}
  17. local HasAlreadyEnteredMarker = false
  18. local LastZone                = nil
  19. local CurrentAction           = nil
  20. local CurrentActionMsg        = ''
  21. local CurrentActionData       = {}
  22. local userProperties          = {}
  23. local this_Garage             = {}
  24. local privateBlips            = {}
  25.  
  26. Citizen.CreateThread(function()
  27.     while ESX == nil do
  28.         TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
  29.         Citizen.Wait(0)
  30.     end
  31.    
  32.     while ESX.GetPlayerData().job == nil do
  33.         Citizen.Wait(10)
  34.     end
  35.  
  36.     ESX.PlayerData = ESX.GetPlayerData()
  37.     refreshBlips()
  38. end)
  39.  
  40. RegisterNetEvent('esx:playerLoaded')
  41. AddEventHandler('esx:playerLoaded', function(xPlayer)
  42.     if Config.UsePrivateCarGarages == true then
  43.         ESX.TriggerServerCallback('esx_advancedgarage:getOwnedProperties', function(properties)
  44.             userProperties = properties
  45.             PrivateGarageBlips()
  46.         end)
  47.     end
  48.    
  49.     ESX.PlayerData = xPlayer
  50.     refreshBlips()
  51. end)
  52.  
  53. RegisterNetEvent('esx:setJob')
  54. AddEventHandler('esx:setJob', function(job)
  55.     ESX.PlayerData.job = job
  56.     deleteBlips()
  57.     refreshBlips()
  58. end)
  59.  
  60. local function has_value (tab, val)
  61.     for index, value in ipairs(tab) do
  62.         if value == val then
  63.             return true
  64.         end
  65.     end
  66.     return false
  67. end
  68.  
  69. -- Open Main Menu
  70. function OpenMenuGarage(PointType)
  71.     ESX.UI.Menu.CloseAll()
  72.    
  73.     local elements = {}
  74.    
  75.     if PointType == 'car_garage_point' then
  76.         table.insert(elements, {label = _U('list_owned_cars'), value = 'list_owned_cars'})
  77.     elseif PointType == 'boat_garage_point' then
  78.         table.insert(elements, {label = _U('list_owned_boats'), value = 'list_owned_boats'})
  79.     elseif PointType == 'aircraft_garage_point' then
  80.         table.insert(elements, {label = _U('list_owned_aircrafts'), value = 'list_owned_aircrafts'})
  81.     elseif PointType == 'car_store_point' then
  82.         table.insert(elements, {label = _U('store_owned_cars'), value = 'store_owned_cars'})
  83.     elseif PointType == 'boat_store_point' then
  84.         table.insert(elements, {label = _U('store_owned_boats'), value = 'store_owned_boats'})
  85.     elseif PointType == 'aircraft_store_point' then
  86.         table.insert(elements, {label = _U('store_owned_aircrafts'), value = 'store_owned_aircrafts'})
  87.     elseif PointType == 'car_pound_point' then
  88.         table.insert(elements, {label = _U('return_owned_cars').." ($"..Config.CarPoundPrice..")", value = 'return_owned_cars'})
  89.     elseif PointType == 'boat_pound_point' then
  90.         table.insert(elements, {label = _U('return_owned_boats').." ($"..Config.BoatPoundPrice..")", value = 'return_owned_boats'})
  91.     elseif PointType == 'aircraft_pound_point' then
  92.         table.insert(elements, {label = _U('return_owned_aircrafts').." ($"..Config.AircraftPoundPrice..")", value = 'return_owned_aircrafts'})
  93.     --[[elseif PointType == 'policing_pound_point' then
  94.         table.insert(elements, {label = _U('return_owned_policing').." ($"..Config.PolicingPoundPrice..")", value = 'return_owned_policing'})
  95.     elseif PointType == 'ambulance_pound_point' then
  96.         table.insert(elements, {label = _U('return_owned_ambulance').." ($"..Config.AmbulancePoundPrice..")", value = 'return_owned_ambulance'})]]--
  97.     end
  98.    
  99.     ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'garage_menu', {
  100.         title    = _U('garage'),
  101.         align    = 'top-left',
  102.         elements = elements
  103.     }, function(data, menu)
  104.         menu.close()
  105.         local action = data.current.value
  106.        
  107.         if action == 'list_owned_cars' then
  108.             ListOwnedCarsMenu()
  109.         elseif action == 'list_owned_boats' then
  110.             ListOwnedBoatsMenu()
  111.         elseif action == 'list_owned_aircrafts' then
  112.             ListOwnedAircraftsMenu()
  113.         elseif action== 'store_owned_cars' then
  114.             StoreOwnedCarsMenu()
  115.         elseif action== 'store_owned_boats' then
  116.             StoreOwnedBoatsMenu()
  117.         elseif action== 'store_owned_aircrafts' then
  118.             StoreOwnedAircraftsMenu()
  119.         elseif action == 'return_owned_cars' then
  120.             ReturnOwnedCarsMenu()
  121.         elseif action == 'return_owned_boats' then
  122.             ReturnOwnedBoatsMenu()
  123.         elseif action == 'return_owned_aircrafts' then
  124.             ReturnOwnedAircraftsMenu()
  125.         --[[elseif action == 'return_owned_policing' then
  126.             ReturnOwnedPolicingMenu()
  127.         elseif action == 'return_owned_ambulance' then
  128.             ReturnOwnedAmbulanceMenu()]]--
  129.         end
  130.     end, function(data, menu)
  131.         menu.close()
  132.     end)
  133. end
  134.  
  135. -- List Owned Cars Menu
  136. function ListOwnedCarsMenu()
  137.     local elements = {}
  138.    
  139.     if Config.ShowGarageSpacer1 then
  140.         table.insert(elements, {label = _U('spacer1')})
  141.     end
  142.    
  143.     if Config.ShowGarageSpacer2 then
  144.         table.insert(elements, {label = _U('spacer2')})
  145.     end
  146.    
  147.     if Config.ShowGarageSpacer3 then
  148.         table.insert(elements, {label = _U('spacer3')})
  149.     end
  150.    
  151.     ESX.TriggerServerCallback('esx_advancedgarage:getOwnedCars', function(ownedCars)
  152.         if #ownedCars == 0 then
  153.             ESX.ShowNotification(_U('garage_nocars'))
  154.         else
  155.             for _,v in pairs(ownedCars) do
  156.                 if Config.UseVehicleNamesLua then
  157.                     local hashVehicule = v.vehicle.model
  158.                     local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  159.                     local vehicleName  = GetLabelText(aheadVehName)
  160.                     local plate        = v.plate
  161.                     local labelvehicle
  162.                    
  163.                     if Config.ShowVehicleLocation then
  164.                         if v.stored then
  165.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..' /'
  166.                         else
  167.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..' /'
  168.                         end
  169.                     else
  170.                         if v.stored then
  171.                             labelvehicle = ''..plate..' / '..vehicleName..''
  172.                         else
  173.                             labelvehicle = ''..plate..' / '..vehicleName..''
  174.                         end
  175.                     end
  176.                    
  177.                     table.insert(elements, {label = labelvehicle, value = v})
  178.                 else
  179.                     local hashVehicule = v.vehicle.model
  180.                     local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  181.                     local plate        = v.plate
  182.                     local labelvehicle
  183.                    
  184.                     if Config.ShowVehicleLocation then
  185.                         if v.stored then
  186.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..''
  187.                         else
  188.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..''
  189.                         end
  190.                     else
  191.                         if v.stored then
  192.                             labelvehicle = ''..plate..' / '..vehicleName..''
  193.                         else
  194.                             labelvehicle = ''..plate..' / '..vehicleName..''
  195.                         end
  196.                     end
  197.                    
  198.                     table.insert(elements, {label = labelvehicle, value = v})
  199.                 end
  200.             end
  201.         end
  202.        
  203.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'spawn_owned_car', {
  204.             title    = _U('garage_cars'),
  205.             align    = 'top-left',
  206.             elements = elements
  207.         }, function(data, menu)
  208.             if data.current.value.stored then
  209.                 menu.close()
  210.                 SpawnVehicle(data.current.value.vehicle, data.current.value.plate)
  211.             else
  212.                 ESX.ShowNotification(_U('car_is_impounded'))
  213.             end
  214.         end, function(data, menu)
  215.             menu.close()
  216.         end)
  217.     end)
  218. end
  219.  
  220. -- List Owned Boats Menu
  221. function ListOwnedBoatsMenu()
  222.     local elements = {}
  223.    
  224.     if Config.ShowGarageSpacer1 then
  225.         table.insert(elements, {label = _U('spacer1')})
  226.     end
  227.    
  228.     if Config.ShowGarageSpacer2 then
  229.         table.insert(elements, {label = _U('spacer2')})
  230.     end
  231.    
  232.     if Config.ShowGarageSpacer3 then
  233.         table.insert(elements, {label = _U('spacer3')})
  234.     end
  235.    
  236.     ESX.TriggerServerCallback('esx_advancedgarage:getOwnedBoats', function(ownedBoats)
  237.         if #ownedBoats == 0 then
  238.             ESX.ShowNotification(_U('garage_noboats'))
  239.         else
  240.             for _,v in pairs(ownedBoats) do
  241.                 if Config.UseVehicleNamesLua then
  242.                     local hashVehicule = v.vehicle.model
  243.                     local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  244.                     local vehicleName  = GetLabelText(aheadVehName)
  245.                     local plate        = v.plate
  246.                     local labelvehicle
  247.                    
  248.                     if Config.ShowVehicleLocation then
  249.                         if v.stored then
  250.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..''
  251.                         else
  252.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..''
  253.                         end
  254.                     else
  255.                         if v.stored then
  256.                             labelvehicle = ''..plate..' / '..vehicleName..''
  257.                         else
  258.                             labelvehicle = ''..plate..' / '..vehicleName..''
  259.                         end
  260.                     end
  261.                    
  262.                     table.insert(elements, {label = labelvehicle, value = v})
  263.                 else
  264.                     local hashVehicule = v.vehicle.model
  265.                     local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  266.                     local plate        = v.plate
  267.                     local labelvehicle
  268.                    
  269.                     if Config.ShowVehicleLocation then
  270.                         if v.stored then
  271.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..''
  272.                         else
  273.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..''
  274.                         end
  275.                     else
  276.                         if v.stored then
  277.                             labelvehicle = ''..plate..' / '..vehicleName..''
  278.                         else
  279.                             labelvehicle = ''..plate..' / '..vehicleName..''
  280.                         end
  281.                     end
  282.                    
  283.                     table.insert(elements, {label = labelvehicle, value = v})
  284.                 end
  285.             end
  286.         end
  287.        
  288.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'spawn_owned_boat', {
  289.             title    = _U('garage_boats'),
  290.             align    = 'top-left',
  291.             elements = elements
  292.         }, function(data, menu)
  293.             if data.current.value.stored then
  294.                 menu.close()
  295.                 SpawnVehicle(data.current.value.vehicle, data.current.value.plate)
  296.             else
  297.                 ESX.ShowNotification(_U('boat_is_impounded'))
  298.             end
  299.         end, function(data, menu)
  300.             menu.close()
  301.         end)
  302.     end)
  303. end
  304.  
  305. -- List Owned Aircrafts Menu
  306. function ListOwnedAircraftsMenu()
  307.     local elements = {}
  308.    
  309.     if Config.ShowGarageSpacer1 then
  310.         table.insert(elements, {label = _U('spacer1')})
  311.     end
  312.    
  313.     if Config.ShowGarageSpacer2 then
  314.         table.insert(elements, {label = _U('spacer2')})
  315.     end
  316.    
  317.     if Config.ShowGarageSpacer3 then
  318.         table.insert(elements, {label = _U('spacer3')})
  319.     end
  320.    
  321.     ESX.TriggerServerCallback('esx_advancedgarage:getOwnedAircrafts', function(ownedAircrafts)
  322.         if #ownedAircrafts == 0 then
  323.             ESX.ShowNotification(_U('garage_noaircrafts'))
  324.         else
  325.             for _,v in pairs(ownedAircrafts) do
  326.                 if Config.UseVehicleNamesLua then
  327.                     local hashVehicule = v.vehicle.model
  328.                     local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  329.                     local vehicleName  = GetLabelText(aheadVehName)
  330.                     local plate        = v.plate
  331.                     local labelvehicle
  332.                    
  333.                     if Config.ShowVehicleLocation then
  334.                         if v.stored then
  335.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..''
  336.                         else
  337.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..''
  338.                         end
  339.                     else
  340.                         if v.stored then
  341.                             labelvehicle = ''..plate..' / '..vehicleName..''
  342.                         else
  343.                             labelvehicle = ''..plate..' / '..vehicleName..''
  344.                         end
  345.                     end
  346.                    
  347.                     table.insert(elements, {label = labelvehicle, value = v})
  348.                 else
  349.                     local hashVehicule = v.vehicle.model
  350.                     local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  351.                     local plate        = v.plate
  352.                     local labelvehicle
  353.                    
  354.                     if Config.ShowVehicleLocation then
  355.                         if v.stored then
  356.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_garage')..''
  357.                         else
  358.                             labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('loc_pound')..''
  359.                         end
  360.                     else
  361.                         if v.stored then
  362.                             labelvehicle = ''..plate..' / '..vehicleName..''
  363.                         else
  364.                             labelvehicle = ''..plate..' / '..vehicleName..''
  365.                         end
  366.                     end
  367.                    
  368.                     table.insert(elements, {label = labelvehicle, value = v})
  369.                 end
  370.             end
  371.         end
  372.        
  373.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'spawn_owned_aircraft', {
  374.             title    = _U('garage_aircrafts'),
  375.             align    = 'top-left',
  376.             elements = elements
  377.         }, function(data, menu)
  378.             if data.current.value.stored then
  379.                 menu.close()
  380.                 SpawnVehicle(data.current.value.vehicle, data.current.value.plate)
  381.             else
  382.                 ESX.ShowNotification(_U('aircraft_is_impounded'))
  383.             end
  384.         end, function(data, menu)
  385.             menu.close()
  386.         end)
  387.     end)
  388. end
  389.  
  390. -- Store Owned Cars Menu
  391. function StoreOwnedCarsMenu()
  392.     local playerPed  = GetPlayerPed(-1)
  393.     if IsPedInAnyVehicle(playerPed,  false) then
  394.         local playerPed    = GetPlayerPed(-1)
  395.         local coords       = GetEntityCoords(playerPed)
  396.         local vehicle      = GetVehiclePedIsIn(playerPed, false)
  397.         local vehicleProps = ESX.Game.GetVehicleProperties(vehicle)
  398.         local current      = GetPlayersLastVehicle(GetPlayerPed(-1), true)
  399.         local engineHealth = GetVehicleEngineHealth(current)
  400.         local plate        = vehicleProps.plate
  401.        
  402.         ESX.TriggerServerCallback('esx_advancedgarage:storeVehicle', function(valid)
  403.             if valid then
  404.                 if engineHealth < 990 then
  405.                     if Config.UseDamageMult then
  406.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.CarPoundPrice*Config.DamageMult)
  407.                         reparation(apprasial, vehicle, vehicleProps)
  408.                     else
  409.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.CarPoundPrice)
  410.                         reparation(apprasial, vehicle, vehicleProps)
  411.                     end
  412.                 else
  413.                     putaway(vehicle, vehicleProps)
  414.                 end
  415.             else
  416.                 ESX.ShowNotification(_U('cannot_store_vehicle'))
  417.             end
  418.         end, vehicleProps)
  419.     else
  420.         ESX.ShowNotification(_U('no_vehicle_to_enter'))
  421.     end
  422. end
  423.  
  424. -- Store Owned Boats Menu
  425. function StoreOwnedBoatsMenu()
  426.     local playerPed  = GetPlayerPed(-1)
  427.     if IsPedInAnyVehicle(playerPed,  false) then
  428.         local playerPed     = GetPlayerPed(-1)
  429.         local coords        = GetEntityCoords(playerPed)
  430.         local vehicle       = GetVehiclePedIsIn(playerPed, false)
  431.         local vehicleProps  = ESX.Game.GetVehicleProperties(vehicle)
  432.         local current       = GetPlayersLastVehicle(GetPlayerPed(-1), true)
  433.         local engineHealth  = GetVehicleEngineHealth(current)
  434.         local plate         = vehicleProps.plate
  435.        
  436.         ESX.TriggerServerCallback('esx_advancedgarage:storeVehicle', function(valid)
  437.             if valid then
  438.                 if engineHealth < 990 then
  439.                     if Config.UseDamageMult then
  440.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.BoatPoundPrice*Config.DamageMult)
  441.                         reparation(apprasial, vehicle, vehicleProps)
  442.                     else
  443.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.BoatPoundPrice)
  444.                         reparation(apprasial, vehicle, vehicleProps)
  445.                     end
  446.                 else
  447.                     putaway(vehicle, vehicleProps)
  448.                 end
  449.             else
  450.                 ESX.ShowNotification(_U('cannot_store_vehicle'))
  451.             end
  452.         end, vehicleProps)
  453.     else
  454.         ESX.ShowNotification(_U('no_vehicle_to_enter'))
  455.     end
  456. end
  457.  
  458. -- Store Owned Aircrafts Menu
  459. function StoreOwnedAircraftsMenu()
  460.     local playerPed  = GetPlayerPed(-1)
  461.     if IsPedInAnyVehicle(playerPed,  false) then
  462.         local playerPed     = GetPlayerPed(-1)
  463.         local coords        = GetEntityCoords(playerPed)
  464.         local vehicle       = GetVehiclePedIsIn(playerPed, false)
  465.         local vehicleProps  = ESX.Game.GetVehicleProperties(vehicle)
  466.         local current       = GetPlayersLastVehicle(GetPlayerPed(-1), true)
  467.         local engineHealth  = GetVehicleEngineHealth(current)
  468.         local plate         = vehicleProps.plate
  469.        
  470.         ESX.TriggerServerCallback('esx_advancedgarage:storeVehicle', function(valid)
  471.             if valid then
  472.                 if engineHealth < 990 then
  473.                     if Config.UseDamageMult then
  474.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.AircraftPoundPrice*Config.DamageMult)
  475.                         reparation(apprasial, vehicle, vehicleProps)
  476.                     else
  477.                         local apprasial = math.floor((1000 - engineHealth)/1000*Config.AircraftPoundPrice)
  478.                         reparation(apprasial, vehicle, vehicleProps)
  479.                     end
  480.                 else
  481.                     putaway(vehicle, vehicleProps)
  482.                 end
  483.             else
  484.                 ESX.ShowNotification(_U('cannot_store_vehicle'))
  485.             end
  486.         end, vehicleProps)
  487.     else
  488.         ESX.ShowNotification(_U('no_vehicle_to_enter'))
  489.     end
  490. end
  491.  
  492. -- Pound Owned Cars Menu
  493. function ReturnOwnedCarsMenu()
  494.     ESX.TriggerServerCallback('esx_advancedgarage:getOutOwnedCars', function(ownedCars)
  495.         local elements = {}
  496.        
  497.         if Config.ShowPoundSpacer2 then
  498.             table.insert(elements, {label = _U('spacer2')})
  499.         end
  500.        
  501.         if Config.ShowPoundSpacer3 then
  502.             table.insert(elements, {label = _U('spacer3')})
  503.         end
  504.        
  505.         for _,v in pairs(ownedCars) do
  506.             if Config.UseVehicleNamesLua then
  507.                 local hashVehicule = v.model
  508.                 local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  509.                 local vehicleName  = GetLabelText(aheadVehName)
  510.                 local plate        = v.plate
  511.                 local labelvehicle
  512.                
  513.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  514.                
  515.                 table.insert(elements, {label = labelvehicle, value = v})
  516.             else
  517.                 local hashVehicule = v.model
  518.                 local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  519.                 local plate        = v.plate
  520.                 local labelvehicle
  521.                
  522.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  523.                
  524.                 table.insert(elements, {label = labelvehicle, value = v})
  525.             end
  526.         end
  527.        
  528.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'return_owned_car', {
  529.             title    = _U('pound_cars'),
  530.             align    = 'top-left',
  531.             elements = elements
  532.         }, function(data, menu)
  533.             ESX.TriggerServerCallback('esx_advancedgarage:checkMoneyCars', function(hasEnoughMoney)
  534.                 if hasEnoughMoney then
  535.                     TriggerServerEvent('esx_advancedgarage:payCar')
  536.                     SpawnPoundedVehicle(data.current.value, data.current.value.plate)
  537.                 else
  538.                     ESX.ShowNotification(_U('not_enough_money'))
  539.                 end
  540.             end)
  541.         end, function(data, menu)
  542.             menu.close()
  543.         end)
  544.     end)
  545. end
  546.  
  547. -- Pound Owned Boats Menu
  548. function ReturnOwnedBoatsMenu()
  549.     ESX.TriggerServerCallback('esx_advancedgarage:getOutOwnedBoats', function(ownedBoats)
  550.         local elements = {}
  551.        
  552.         if Config.ShowPoundSpacer2 then
  553.             table.insert(elements, {label = _U('spacer2')})
  554.         end
  555.        
  556.         if Config.ShowPoundSpacer3 then
  557.             table.insert(elements, {label = _U('spacer3')})
  558.         end
  559.        
  560.         for _,v in pairs(ownedBoats) do
  561.             if Config.UseVehicleNamesLua then
  562.                 local hashVehicule = v.model
  563.                 local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  564.                 local vehicleName  = GetLabelText(aheadVehName)
  565.                 local plate        = v.plate
  566.                 local labelvehicle
  567.                
  568.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  569.                
  570.                 table.insert(elements, {label = labelvehicle, value = v})
  571.             else
  572.                 local hashVehicule = v.model
  573.                 local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  574.                 local plate        = v.plate
  575.                 local labelvehicle
  576.                
  577.                 labelvehicle = ' '..plate..' / '..vehicleName..' / '.._U('return')..''
  578.                
  579.                 table.insert(elements, {label = labelvehicle, value = v})
  580.             end
  581.         end
  582.        
  583.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'return_owned_boat', {
  584.             title    = _U('pound_boats'),
  585.             align    = 'top-left',
  586.             elements = elements
  587.         }, function(data, menu)
  588.             ESX.TriggerServerCallback('esx_advancedgarage:checkMoneyBoats', function(hasEnoughMoney)
  589.                 if hasEnoughMoney then
  590.                     TriggerServerEvent('esx_advancedgarage:payBoat')
  591.                     SpawnPoundedVehicle(data.current.value, data.current.value.plate)
  592.                 else
  593.                     ESX.ShowNotification(_U('not_enough_money'))
  594.                 end
  595.             end)
  596.         end, function(data, menu)
  597.             menu.close()
  598.         end)
  599.     end)
  600. end
  601.  
  602. -- Pound Owned Aircrafts Menu
  603. function ReturnOwnedAircraftsMenu()
  604.     ESX.TriggerServerCallback('esx_advancedgarage:getOutOwnedAircrafts', function(ownedAircrafts)
  605.         local elements = {}
  606.        
  607.         if Config.ShowPoundSpacer2 then
  608.             table.insert(elements, {label = _U('spacer2')})
  609.         end
  610.        
  611.         if Config.ShowPoundSpacer3 then
  612.             table.insert(elements, {label = _U('spacer3')})
  613.         end
  614.        
  615.         for _,v in pairs(ownedAircrafts) do
  616.             if Config.UseVehicleNamesLua then
  617.                 local hashVehicule = v.model
  618.                 local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  619.                 local vehicleName  = GetLabelText(aheadVehName)
  620.                 local plate        = v.plate
  621.                 local labelvehicle
  622.                
  623.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  624.                
  625.                 table.insert(elements, {label = labelvehicle, value = v})
  626.             else
  627.                 local hashVehicule = v.model
  628.                 local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  629.                 local plate        = v.plate
  630.                 local labelvehicle
  631.                
  632.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  633.                
  634.                 table.insert(elements, {label = labelvehicle, value = v})
  635.             end
  636.         end
  637.        
  638.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'return_owned_aircraft', {
  639.             title    = _U('pound_aircrafts'),
  640.             align    = 'top-left',
  641.             elements = elements
  642.         }, function(data, menu)
  643.             ESX.TriggerServerCallback('esx_advancedgarage:checkMoneyAircrafts', function(hasEnoughMoney)
  644.                 if hasEnoughMoney then
  645.                     TriggerServerEvent('esx_advancedgarage:payAircraft')
  646.                     SpawnPoundedVehicle(data.current.value, data.current.value.plate)
  647.                 else
  648.                     ESX.ShowNotification(_U('not_enough_money'))
  649.                 end
  650.             end)
  651.         end, function(data, menu)
  652.             menu.close()
  653.         end)
  654.     end)
  655. end
  656.  
  657. -- Pound Owned Policing Menu
  658. --[[function ReturnOwnedPolicingMenu()
  659.     ESX.TriggerServerCallback('esx_advancedgarage:getOutOwnedPolicingCars', function(ownedPolicingCars)
  660.         local elements = {}
  661.        
  662.         if Config.ShowPoundSpacer2 then
  663.             table.insert(elements, {label = _U('spacer2')})
  664.         end
  665.        
  666.         if Config.ShowPoundSpacer3 then
  667.             table.insert(elements, {label = _U('spacer3')})
  668.         end
  669.        
  670.         for _,v in pairs(ownedPolicingCars) do
  671.             if Config.UseVehicleNamesLua then
  672.                 local hashVehicule = v.model
  673.                 local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  674.                 local vehicleName  = GetLabelText(aheadVehName)
  675.                 local plate        = v.plate
  676.                 local labelvehicle
  677.                
  678.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  679.                
  680.                 table.insert(elements, {label = labelvehicle, value = v})
  681.             else
  682.                 local hashVehicule = v.model
  683.                 local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  684.                 local plate        = v.plate
  685.                 local labelvehicle
  686.                
  687.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  688.                
  689.                 table.insert(elements, {label = labelvehicle, value = v})
  690.             end
  691.         end
  692.        
  693.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'return_owned_policing', {
  694.             title    = _U('pound_police'),
  695.             align    = 'top-left',
  696.             elements = elements
  697.         }, function(data, menu)
  698.             ESX.TriggerServerCallback('esx_advancedgarage:checkMoneyPolicing', function(hasEnoughMoney)
  699.                 if hasEnoughMoney then
  700.                     TriggerServerEvent('esx_advancedgarage:payPolicing')
  701.                     SpawnPoundedVehicle(data.current.value, data.current.value.plate)
  702.                 else
  703.                     ESX.ShowNotification(_U('not_enough_money'))
  704.                 end
  705.             end)
  706.         end, function(data, menu)
  707.             menu.close()
  708.         end)
  709.     end)
  710. end
  711.  
  712. -- Pound Owned Ambulance Menu
  713. function ReturnOwnedAmbulanceMenu()
  714.     ESX.TriggerServerCallback('esx_advancedgarage:getOutOwnedAmbulanceCars', function(ownedAmbulanceCars)
  715.         local elements = {}
  716.        
  717.         if Config.ShowPoundSpacer2 then
  718.             table.insert(elements, {label = _U('spacer2')})
  719.         end
  720.        
  721.         if Config.ShowPoundSpacer3 then
  722.             table.insert(elements, {label = _U('spacer3')})
  723.         end
  724.        
  725.         for _,v in pairs(ownedAmbulanceCars) do
  726.             if Config.UseVehicleNamesLua then
  727.                 local hashVehicule = v.model
  728.                 local aheadVehName = GetDisplayNameFromVehicleModel(hashVehicule)
  729.                 local vehicleName  = GetLabelText(aheadVehName)
  730.                 local plate        = v.plate
  731.                 local labelvehicle
  732.                
  733.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  734.                
  735.                 table.insert(elements, {label = labelvehicle, value = v})
  736.             else
  737.                 local hashVehicule = v.model
  738.                 local vehicleName  = GetDisplayNameFromVehicleModel(hashVehicule)
  739.                 local plate        = v.plate
  740.                 local labelvehicle
  741.                
  742.                 labelvehicle = ''..plate..' / '..vehicleName..' / '.._U('return')..''
  743.                
  744.                 table.insert(elements, {label = labelvehicle, value = v})
  745.             end
  746.         end
  747.        
  748.         ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'return_owned_ambulance', {
  749.             title    = _U('pound_ambulance'),
  750.             align    = 'top-left',
  751.             elements = elements
  752.         }, function(data, menu)
  753.             ESX.TriggerServerCallback('esx_advancedgarage:checkMoneyAmbulance', function(hasEnoughMoney)
  754.                 if hasEnoughMoney then
  755.                     TriggerServerEvent('esx_advancedgarage:payAmbulance')
  756.                     SpawnPoundedVehicle(data.current.value, data.current.value.plate)
  757.                 else
  758.                     ESX.ShowNotification(_U('not_enough_money'))
  759.                 end
  760.             end)
  761.         end, function(data, menu)
  762.             menu.close()
  763.         end)
  764.     end)
  765. end]]--
  766.  
  767. -- Repair Vehicles
  768. function reparation(apprasial, vehicle, vehicleProps)
  769.     ESX.UI.Menu.CloseAll()
  770.    
  771.     local elements = {
  772.         {label = _U('return_vehicle').." ($"..apprasial..")", value = 'yes'},
  773.         {label = _U('see_mechanic'), value = 'no'}
  774.     }
  775.    
  776.     ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'delete_menu', {
  777.         title    = _U('damaged_vehicle'),
  778.         align    = 'top-left',
  779.         elements = elements
  780.     }, function(data, menu)
  781.         menu.close()
  782.        
  783.         if data.current.value == 'yes' then
  784.             TriggerServerEvent('esx_advancedgarage:payhealth', apprasial)
  785.             putaway(vehicle, vehicleProps)
  786.         elseif data.current.value == 'no' then
  787.             ESX.ShowNotification(_U('visit_mechanic'))
  788.         end
  789.     end, function(data, menu)
  790.         menu.close()
  791.     end)
  792. end
  793.  
  794. -- Put Away Vehicles
  795. function putaway(vehicle, vehicleProps)
  796.     ESX.Game.DeleteVehicle(vehicle)
  797.     TriggerServerEvent('esx_advancedgarage:setVehicleState', vehicleProps.plate, true)
  798.     ESX.ShowNotification(_U('vehicle_in_garage'))
  799. end
  800.  
  801. -- Spawn Cars
  802. function SpawnVehicle(vehicle, plate)
  803.     ESX.Game.SpawnVehicle(vehicle.model, {
  804.         x = this_Garage.SpawnPoint.x,
  805.         y = this_Garage.SpawnPoint.y,
  806.         z = this_Garage.SpawnPoint.z + 1
  807.     }, this_Garage.SpawnPoint.h, function(callback_vehicle)
  808.         ESX.Game.SetVehicleProperties(callback_vehicle, vehicle)
  809.         SetVehRadioStation(callback_vehicle, "OFF")
  810.         TaskWarpPedIntoVehicle(GetPlayerPed(-1), callback_vehicle, -1)
  811.     end)
  812.    
  813.     TriggerServerEvent('esx_advancedgarage:setVehicleState', plate, false)
  814. end
  815.  
  816. -- Spawn Pound Cars
  817. function SpawnPoundedVehicle(vehicle, plate)
  818.     ESX.Game.SpawnVehicle(vehicle.model, {
  819.         x = this_Garage.SpawnPoint.x,
  820.         y = this_Garage.SpawnPoint.y,
  821.         z = this_Garage.SpawnPoint.z + 1
  822.     }, this_Garage.SpawnPoint.h, function(callback_vehicle)
  823.         ESX.Game.SetVehicleProperties(callback_vehicle, vehicle)
  824.         SetVehRadioStation(callback_vehicle, "OFF")
  825.         TaskWarpPedIntoVehicle(GetPlayerPed(-1), callback_vehicle, -1)
  826.     end)
  827.    
  828.     TriggerServerEvent('esx_advancedgarage:setVehicleState', plate, false)
  829. end
  830.  
  831. -- Entered Marker
  832. AddEventHandler('esx_advancedgarage:hasEnteredMarker', function(zone)
  833.     if zone == 'car_garage_point' then
  834.         CurrentAction     = 'car_garage_point'
  835.         CurrentActionMsg  = _U('press_to_enter')
  836.         CurrentActionData = {}
  837.     elseif zone == 'boat_garage_point' then
  838.         CurrentAction     = 'boat_garage_point'
  839.         CurrentActionMsg  = _U('press_to_enter')
  840.         CurrentActionData = {}
  841.     elseif zone == 'aircraft_garage_point' then
  842.         CurrentAction     = 'aircraft_garage_point'
  843.         CurrentActionMsg  = _U('press_to_enter')
  844.         CurrentActionData = {}
  845.     elseif zone == 'car_store_point' then
  846.         CurrentAction     = 'car_store_point'
  847.         CurrentActionMsg  = _U('press_to_delete')
  848.         CurrentActionData = {}
  849.     elseif zone == 'boat_store_point' then
  850.         CurrentAction     = 'boat_store_point'
  851.         CurrentActionMsg  = _U('press_to_delete')
  852.         CurrentActionData = {}
  853.     elseif zone == 'aircraft_store_point' then
  854.         CurrentAction     = 'aircraft_store_point'
  855.         CurrentActionMsg  = _U('press_to_delete')
  856.         CurrentActionData = {}
  857.     elseif zone == 'car_pound_point' then
  858.         CurrentAction     = 'car_pound_point'
  859.         CurrentActionMsg  = _U('press_to_impound')
  860.         CurrentActionData = {}
  861.     elseif zone == 'boat_pound_point' then
  862.         CurrentAction     = 'boat_pound_point'
  863.         CurrentActionMsg  = _U('press_to_impound')
  864.         CurrentActionData = {}
  865.     elseif zone == 'aircraft_pound_point' then
  866.         CurrentAction     = 'aircraft_pound_point'
  867.         CurrentActionMsg  = _U('press_to_impound')
  868.         CurrentActionData = {}
  869.     --[[elseif zone == 'policing_pound_point' then
  870.         CurrentAction     = 'policing_pound_point'
  871.         CurrentActionMsg  = _U('press_to_impound')
  872.         CurrentActionData = {}
  873.     elseif zone == 'ambulance_pound_point' then
  874.         CurrentAction     = 'ambulance_pound_point'
  875.         CurrentActionMsg  = _U('press_to_impound')
  876.         CurrentActionData = {}]]--
  877.     end
  878. end)
  879.  
  880. -- Exited Marker
  881. AddEventHandler('esx_advancedgarage:hasExitedMarker', function()
  882.     ESX.UI.Menu.CloseAll()
  883.     CurrentAction = nil
  884. end)
  885.  
  886. -- Draw Markers
  887. Citizen.CreateThread(function()
  888.     while true do
  889.         Citizen.Wait(1)
  890.        
  891.         local playerPed = PlayerPedId()
  892.         local coords    = GetEntityCoords(playerPed)
  893.         local canSleep  = true
  894.        
  895.         if Config.UseCarGarages then
  896.             for k,v in pairs(Config.CarGarages) do
  897.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.DrawDistance) then
  898.                     canSleep = false
  899.                     DrawMarker(Config.MarkerType, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PointMarker.x, Config.PointMarker.y, Config.PointMarker.z, Config.PointMarker.r, Config.PointMarker.g, Config.PointMarker.b, 100, false, true, 2, false, false, false, false)  
  900.                     DrawMarker(Config.MarkerType, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.DeleteMarker.x, Config.DeleteMarker.y, Config.DeleteMarker.z, Config.DeleteMarker.r, Config.DeleteMarker.g, Config.DeleteMarker.b, 100, false, true, 2, false, false, false, false)
  901.                 end
  902.             end
  903.            
  904.             for k,v in pairs(Config.CarPounds) do
  905.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.DrawDistance) then
  906.                     canSleep = false
  907.                     DrawMarker(Config.MarkerType, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PoundMarker.x, Config.PoundMarker.y, Config.PoundMarker.z, Config.PoundMarker.r, Config.PoundMarker.g, Config.PoundMarker.b, 100, false, true, 2, false, false, false, false)
  908.                 end
  909.             end
  910.         end
  911.        
  912.         if Config.UseBoatGarages then
  913.             for k,v in pairs(Config.BoatGarages) do
  914.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.DrawDistance) then
  915.                     canSleep = false
  916.                     DrawMarker(Config.MarkerType, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PointMarker.x, Config.PointMarker.y, Config.PointMarker.z, Config.PointMarker.r, Config.PointMarker.g, Config.PointMarker.b, 100, false, true, 2, false, false, false, false)  
  917.                     DrawMarker(Config.MarkerType, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.DeleteMarker.x, Config.DeleteMarker.y, Config.DeleteMarker.z, Config.DeleteMarker.r, Config.DeleteMarker.g, Config.DeleteMarker.b, 100, false, true, 2, false, false, false, false)
  918.                 end
  919.             end
  920.            
  921.             for k,v in pairs(Config.BoatPounds) do
  922.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.DrawDistance) then
  923.                     canSleep = false
  924.                     DrawMarker(Config.MarkerType, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PoundMarker.x, Config.PoundMarker.y, Config.PoundMarker.z, Config.PoundMarker.r, Config.PoundMarker.g, Config.PoundMarker.b, 100, false, true, 2, false, false, false, false)
  925.                 end
  926.             end
  927.         end
  928.        
  929.         if Config.UseAircraftGarages then
  930.             for k,v in pairs(Config.AircraftGarages) do
  931.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.DrawDistance) then
  932.                     canSleep = false
  933.                     DrawMarker(Config.MarkerType, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PointMarker.x, Config.PointMarker.y, Config.PointMarker.z, Config.PointMarker.r, Config.PointMarker.g, Config.PointMarker.b, 100, false, true, 2, false, false, false, false)  
  934.                     DrawMarker(Config.MarkerType, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.DeleteMarker.x, Config.DeleteMarker.y, Config.DeleteMarker.z, Config.DeleteMarker.r, Config.DeleteMarker.g, Config.DeleteMarker.b, 100, false, true, 2, false, false, false, false)
  935.                 end
  936.             end
  937.            
  938.             for k,v in pairs(Config.AircraftPounds) do
  939.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.DrawDistance) then
  940.                     canSleep = false
  941.                     DrawMarker(Config.MarkerType, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PoundMarker.x, Config.PoundMarker.y, Config.PoundMarker.z, Config.PoundMarker.r, Config.PoundMarker.g, Config.PoundMarker.b, 100, false, true, 2, false, false, false, false)
  942.                 end
  943.             end
  944.         end
  945.        
  946.         if Config.UsePrivateCarGarages then
  947.             for k,v in pairs(Config.PrivateCarGarages) do
  948.                 if not v.Private or has_value(userProperties, v.Private) then
  949.                     if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.DrawDistance) then
  950.                         canSleep = false
  951.                         DrawMarker(Config.MarkerType, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.PointMarker.x, Config.PointMarker.y, Config.PointMarker.z, Config.PointMarker.r, Config.PointMarker.g, Config.PointMarker.b, 100, false, true, 2, false, false, false, false)  
  952.                         DrawMarker(Config.MarkerType, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.DeleteMarker.x, Config.DeleteMarker.y, Config.DeleteMarker.z, Config.DeleteMarker.r, Config.DeleteMarker.g, Config.DeleteMarker.b, 100, false, true, 2, false, false, false, false)
  953.                     end
  954.                 end
  955.             end
  956.         end
  957.        
  958.         --[[if Config.UseJobCarGarages then
  959.             if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'police' then
  960.                 for k,v in pairs(Config.PolicePounds) do
  961.                     if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.DrawDistance) then
  962.                         canSleep = false
  963.                         DrawMarker(Config.MarkerType, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.JobPoundMarker.x, Config.JobPoundMarker.y, Config.JobPoundMarker.z, Config.JobPoundMarker.r, Config.JobPoundMarker.g, Config.JobPoundMarker.b, 100, false, true, 2, false, false, false, false)
  964.                     end
  965.                 end
  966.             end
  967.            
  968.             if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'ambulance' then
  969.                 for k,v in pairs(Config.AmbulancePounds) do
  970.                     if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.DrawDistance) then
  971.                         canSleep = false
  972.                         DrawMarker(Config.MarkerType, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.JobPoundMarker.x, Config.JobPoundMarker.y, Config.JobPoundMarker.z, Config.JobPoundMarker.r, Config.JobPoundMarker.g, Config.JobPoundMarker.b, 100, false, true, 2, false, false, false, false)
  973.                     end
  974.                 end
  975.             end
  976.         end]]--
  977.        
  978.         if canSleep then
  979.             Citizen.Wait(500)
  980.         end
  981.     end
  982. end)
  983.  
  984. -- Activate Menu when in Markers
  985. Citizen.CreateThread(function()
  986.     local currentZone = 'garage'
  987.     while true do
  988.         Citizen.Wait(1)
  989.        
  990.         local playerPed  = PlayerPedId()
  991.         local coords     = GetEntityCoords(playerPed)
  992.         local isInMarker = false
  993.        
  994.         if Config.UseCarGarages then
  995.             for k,v in pairs(Config.CarGarages) do
  996.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.PointMarker.x) then
  997.                     isInMarker  = true
  998.                     this_Garage = v
  999.                     currentZone = 'car_garage_point'
  1000.                 end
  1001.                
  1002.                 if(GetDistanceBetweenCoords(coords, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, true) < Config.DeleteMarker.x) then
  1003.                     isInMarker  = true
  1004.                     this_Garage = v
  1005.                     currentZone = 'car_store_point'
  1006.                 end
  1007.             end
  1008.            
  1009.             for k,v in pairs(Config.CarPounds) do
  1010.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.PoundMarker.x) then
  1011.                     isInMarker  = true
  1012.                     this_Garage = v
  1013.                     currentZone = 'car_pound_point'
  1014.                 end
  1015.             end
  1016.         end
  1017.        
  1018.         if Config.UseBoatGarages then
  1019.             for k,v in pairs(Config.BoatGarages) do
  1020.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.PointMarker.x) then
  1021.                     isInMarker  = true
  1022.                     this_Garage = v
  1023.                     currentZone = 'boat_garage_point'
  1024.                 end
  1025.                
  1026.                 if(GetDistanceBetweenCoords(coords, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, true) < Config.DeleteMarker.x) then
  1027.                     isInMarker  = true
  1028.                     this_Garage = v
  1029.                     currentZone = 'boat_store_point'
  1030.                 end
  1031.             end
  1032.            
  1033.             for k,v in pairs(Config.BoatPounds) do
  1034.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.PoundMarker.x) then
  1035.                     isInMarker  = true
  1036.                     this_Garage = v
  1037.                     currentZone = 'boat_pound_point'
  1038.                 end
  1039.             end
  1040.         end
  1041.        
  1042.         if Config.UseAircraftGarages then
  1043.             for k,v in pairs(Config.AircraftGarages) do
  1044.                 if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.PointMarker.x) then
  1045.                     isInMarker  = true
  1046.                     this_Garage = v
  1047.                     currentZone = 'aircraft_garage_point'
  1048.                 end
  1049.                
  1050.                 if(GetDistanceBetweenCoords(coords, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, true) < Config.DeleteMarker.x) then
  1051.                     isInMarker  = true
  1052.                     this_Garage = v
  1053.                     currentZone = 'aircraft_store_point'
  1054.                 end
  1055.             end
  1056.            
  1057.             for k,v in pairs(Config.AircraftPounds) do
  1058.                 if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.PoundMarker.x) then
  1059.                     isInMarker  = true
  1060.                     this_Garage = v
  1061.                     currentZone = 'aircraft_pound_point'
  1062.                 end
  1063.             end
  1064.         end
  1065.        
  1066.         if Config.UsePrivateCarGarages then
  1067.             for _,v in pairs(Config.PrivateCarGarages) do
  1068.                 if not v.Private or has_value(userProperties, v.Private) then
  1069.                     if (GetDistanceBetweenCoords(coords, v.GaragePoint.x, v.GaragePoint.y, v.GaragePoint.z, true) < Config.PointMarker.x) then
  1070.                         isInMarker  = true
  1071.                         this_Garage = v
  1072.                         currentZone = 'car_garage_point'
  1073.                     end
  1074.                
  1075.                     if(GetDistanceBetweenCoords(coords, v.DeletePoint.x, v.DeletePoint.y, v.DeletePoint.z, true) < Config.DeleteMarker.x) then
  1076.                         isInMarker  = true
  1077.                         this_Garage = v
  1078.                         currentZone = 'car_store_point'
  1079.                     end
  1080.                 end
  1081.             end
  1082.         end
  1083.        
  1084.         --[[if Config.UseJobCarGarages then
  1085.             if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'police' then
  1086.                 for k,v in pairs(Config.PolicePounds) do
  1087.                     if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.JobPoundMarker.x) then
  1088.                         isInMarker  = true
  1089.                         this_Garage = v
  1090.                         currentZone = 'policing_pound_point'
  1091.                     end
  1092.                 end
  1093.             end
  1094.            
  1095.             if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'ambulance' then
  1096.                 for k,v in pairs(Config.AmbulancePounds) do
  1097.                     if (GetDistanceBetweenCoords(coords, v.PoundPoint.x, v.PoundPoint.y, v.PoundPoint.z, true) < Config.JobPoundMarker.x) then
  1098.                         isInMarker  = true
  1099.                         this_Garage = v
  1100.                         currentZone = 'ambulance_pound_point'
  1101.                     end
  1102.                 end
  1103.             end
  1104.         end]]--
  1105.        
  1106.         if isInMarker and not hasAlreadyEnteredMarker then
  1107.             hasAlreadyEnteredMarker = true
  1108.             LastZone                = currentZone
  1109.             TriggerEvent('esx_advancedgarage:hasEnteredMarker', currentZone)
  1110.         end
  1111.        
  1112.         if not isInMarker and hasAlreadyEnteredMarker then
  1113.             hasAlreadyEnteredMarker = false
  1114.             TriggerEvent('esx_advancedgarage:hasExitedMarker', LastZone)
  1115.         end
  1116.        
  1117.         if not isInMarker then
  1118.             Citizen.Wait(500)
  1119.         end
  1120.     end
  1121. end)
  1122.  
  1123. -- Key Controls
  1124. Citizen.CreateThread(function()
  1125.     while true do
  1126.         Citizen.Wait(0)
  1127.        
  1128.         if CurrentAction ~= nil then
  1129.             ESX.ShowHelpNotification(CurrentActionMsg)
  1130.            
  1131.             if IsControlJustReleased(0, Keys['E']) then
  1132.                 if CurrentAction == 'car_garage_point' then
  1133.                     OpenMenuGarage('car_garage_point')
  1134.                 elseif CurrentAction == 'boat_garage_point' then
  1135.                     OpenMenuGarage('boat_garage_point')
  1136.                 elseif CurrentAction == 'aircraft_garage_point' then
  1137.                     OpenMenuGarage('aircraft_garage_point')
  1138.                 elseif CurrentAction == 'car_store_point' then
  1139.                     OpenMenuGarage('car_store_point')
  1140.                 elseif CurrentAction == 'boat_store_point' then
  1141.                     OpenMenuGarage('boat_store_point')
  1142.                 elseif CurrentAction == 'aircraft_store_point' then
  1143.                     OpenMenuGarage('aircraft_store_point')
  1144.                 elseif CurrentAction == 'car_pound_point' then
  1145.                     OpenMenuGarage('car_pound_point')
  1146.                 elseif CurrentAction == 'boat_pound_point' then
  1147.                     OpenMenuGarage('boat_pound_point')
  1148.                 elseif CurrentAction == 'aircraft_pound_point' then
  1149.                     OpenMenuGarage('aircraft_pound_point')
  1150.                 --[[elseif CurrentAction == 'policing_pound_point' then
  1151.                     OpenMenuGarage('policing_pound_point')
  1152.                 elseif CurrentAction == 'ambulance_pound_point' then
  1153.                     OpenMenuGarage('ambulance_pound_point')]]--
  1154.                 end
  1155.                
  1156.                 CurrentAction = nil
  1157.             end
  1158.         else
  1159.             Citizen.Wait(500)
  1160.         end
  1161.     end
  1162. end)
  1163.  
  1164. -- Create Blips
  1165. function PrivateGarageBlips()
  1166.     for _,blip in pairs(privateBlips) do
  1167.         RemoveBlip(blip)
  1168.     end
  1169.    
  1170.     privateBlips = {}
  1171.    
  1172.     for zoneKey,zoneValues in pairs(Config.PrivateCarGarages) do
  1173.         if zoneValues.Private and has_value(userProperties, zoneValues.Private) then
  1174.             local blip = AddBlipForCoord(zoneValues.GaragePoint.x, zoneValues.GaragePoint.y, zoneValues.GaragePoint.z)
  1175.             SetBlipSprite(blip, Config.BlipGaragePrivate.Sprite)
  1176.             SetBlipDisplay(blip, Config.BlipGaragePrivate.Display)
  1177.             SetBlipScale(blip, Config.BlipGaragePrivate.Scale)
  1178.             SetBlipColour(blip, Config.BlipGaragePrivate.Color)
  1179.             SetBlipAsShortRange(blip, true)
  1180.             BeginTextCommandSetBlipName("STRING")
  1181.             AddTextComponentString(_U('blip_garage_private'))
  1182.             EndTextCommandSetBlipName(blip)
  1183.         end
  1184.     end
  1185. end
  1186.  
  1187. function deleteBlips()
  1188.     if JobBlips[1] ~= nil then
  1189.         for i=1, #JobBlips, 1 do
  1190.             RemoveBlip(JobBlips[i])
  1191.             JobBlips[i] = nil
  1192.         end
  1193.     end
  1194. end
  1195.  
  1196. --[[function refreshBlips()
  1197.     local blipList = {}
  1198.     local JobBlips = {}
  1199.  
  1200.     if Config.UseCarGarages then
  1201.         for k,v in pairs(Config.CarGarages) do
  1202.             table.insert(blipList, {
  1203.                 coords = { v.GaragePoint.x, v.GaragePoint.y },
  1204.                 text   = _U('blip_garage'),
  1205.                 sprite = Config.BlipGarage.Sprite,
  1206.                 color  = Config.BlipGarage.Color,
  1207.                 scale  = Config.BlipGarage.Scale
  1208.             })
  1209.         end
  1210.        
  1211.         for k,v in pairs(Config.CarPounds) do
  1212.             table.insert(blipList, {
  1213.                 coords = { v.PoundPoint.x, v.PoundPoint.y },
  1214.                 text   = _U('blip_pound'),
  1215.                 sprite = Config.BlipPound.Sprite,
  1216.                 color  = Config.BlipPound.Color,
  1217.                 scale  = Config.BlipPound.Scale
  1218.             })
  1219.         end
  1220.     end
  1221.    
  1222.     if Config.UseBoatGarages then
  1223.         for k,v in pairs(Config.BoatGarages) do
  1224.             table.insert(blipList, {
  1225.                 coords = { v.GaragePoint.x, v.GaragePoint.y },
  1226.                 text   = _U('blip_garage'),
  1227.                 sprite = Config.BlipGarage.Sprite,
  1228.                 color  = Config.BlipGarage.Color,
  1229.                 scale  = Config.BlipGarage.Scale
  1230.             })
  1231.         end
  1232.        
  1233.         for k,v in pairs(Config.BoatPounds) do
  1234.             table.insert(blipList, {
  1235.                 coords = { v.PoundPoint.x, v.PoundPoint.y },
  1236.                 text   = _U('blip_pound'),
  1237.                 sprite = Config.BlipPound.Sprite,
  1238.                 color  = Config.BlipPound.Color,
  1239.                 scale  = Config.BlipPound.Scale
  1240.             })
  1241.         end
  1242.     end
  1243.    
  1244.     if Config.UseAircraftGarages then
  1245.         for k,v in pairs(Config.AircraftGarages) do
  1246.             table.insert(blipList, {
  1247.                 coords = { v.GaragePoint.x, v.GaragePoint.y },
  1248.                 text   = _U('blip_garage'),
  1249.                 sprite = Config.BlipGarage.Sprite,
  1250.                 color  = Config.BlipGarage.Color,
  1251.                 scale  = Config.BlipGarage.Scale
  1252.             })
  1253.         end
  1254.        
  1255.         for k,v in pairs(Config.AircraftPounds) do
  1256.             table.insert(blipList, {
  1257.                 coords = { v.PoundPoint.x, v.PoundPoint.y },
  1258.                 text   = _U('blip_pound'),
  1259.                 sprite = Config.BlipPound.Sprite,
  1260.                 color  = Config.BlipPound.Color,
  1261.                 scale  = Config.BlipPound.Scale
  1262.             })
  1263.         end
  1264.     end
  1265.    
  1266.     if Config.UseJobCarGarages then
  1267.         if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'police' then
  1268.             for k,v in pairs(Config.PolicePounds) do
  1269.                 table.insert(JobBlips, {
  1270.                     coords = { v.PoundPoint.x, v.PoundPoint.y },
  1271.                     text   = _U('blip_police_pound'),
  1272.                     sprite = Config.BlipJobPound.Sprite,
  1273.                     color  = Config.BlipJobPound.Color,
  1274.                     scale  = Config.BlipJobPound.Scale
  1275.                 })
  1276.             end
  1277.         end
  1278.        
  1279.         if ESX.PlayerData.job ~= nil and ESX.PlayerData.job.name == 'ambulance' then
  1280.             for k,v in pairs(Config.AmbulancePounds) do
  1281.                 table.insert(JobBlips, {
  1282.                     coords = { v.PoundPoint.x, v.PoundPoint.y },
  1283.                     text   = _U('blip_ambulance_pound'),
  1284.                     sprite = Config.BlipJobPound.Sprite,
  1285.                     color  = Config.BlipJobPound.Color,
  1286.                     scale  = Config.BlipJobPound.Scale
  1287.                 })
  1288.             end
  1289.         end
  1290.     end
  1291.  
  1292.     for i=1, #blipList, 1 do
  1293.         CreateBlip(blipList[i].coords, blipList[i].text, blipList[i].sprite, blipList[i].color, blipList[i].scale)
  1294.     end
  1295.    
  1296.     for i=1, #JobBlips, 1 do
  1297.         CreateBlip(JobBlips[i].coords, JobBlips[i].text, JobBlips[i].sprite, JobBlips[i].color, JobBlips[i].scale)
  1298.     end
  1299. end
  1300.  
  1301. function CreateBlip(coords, text, sprite, color, scale)
  1302.     local blip = AddBlipForCoord(table.unpack(coords))
  1303.    
  1304.     SetBlipSprite(blip, sprite)
  1305.     SetBlipScale(blip, scale)
  1306.     SetBlipColour(blip, color)
  1307.     SetBlipAsShortRange(blip, true)
  1308.    
  1309.     BeginTextCommandSetBlipName('STRING')
  1310.     AddTextComponentSubstringPlayerName(text)
  1311.     EndTextCommandSetBlipName(blip)
  1312.     table.insert(JobBlips, blip)
  1313. end]]--
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement