Advertisement
Guest User

Untitled

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