diff --git a/[esx_addons]/esx_garage/client/main.lua b/[esx_addons]/esx_garage/client/main.lua index 61459696..e7996841 100644 --- a/[esx_addons]/esx_garage/client/main.lua +++ b/[esx_addons]/esx_garage/client/main.lua @@ -128,19 +128,15 @@ end) AddEventHandler('esx_garage:hasEnteredMarker', function(name, part) if part == 'EntryPoint' then + local isInVehicle = IsPedInAnyVehicle(PlayerPedId(), false) local garage = Config.Garages[name] thisGarage = garage - ESX.TextUI(_U('access_parking')) - end - - if part == 'StorePoint' then - local garage = Config.Garages[name] - thisGarage = garage - - local isInVehicle = IsPedInAnyVehicle(PlayerPedId(), false) - - if isInVehicle then ESX.TextUI(_U('park_veh')) end + if isInVehicle then + ESX.TextUI(_U('park_veh')) + else + ESX.TextUI(_U('access_parking')) + end end if part == 'GetOutPoint' then @@ -174,13 +170,6 @@ CreateThread(function() sleep = 0 break end - - if (#(coords - - vector3(v.StorePoint.x, v.StorePoint.y, v.StorePoint.z)) < Config.DrawDistance) then - DrawMarker(Config.Markers.StorePoint.Type, v.StorePoint.x, v.StorePoint.y, v.StorePoint.z, 0.0, 0.0, 0.0, 0, 0.0, 0.0, Config.Markers.StorePoint.Size.x, Config.Markers.StorePoint.Size.y, Config.Markers.StorePoint.Size.z, Config.Markers.StorePoint.Color.r, Config.Markers.StorePoint.Color.g, Config.Markers.StorePoint.Color.b, 100, false, true, 2, false, false, false, false) - - sleep = 0 - end end -- pound @@ -217,167 +206,160 @@ CreateThread(function() isInMarker = true currentMarker = k currentPart = 'EntryPoint' - - if IsControlJustReleased(0, 38) and not menuIsShowed then - ESX.TriggerServerCallback('esx_garage:getVehiclesInParking', - function(vehicles) - if next(vehicles) ~= nil then - menuIsShowed = true - - for i = 1, #vehicles, 1 do - table.insert(vehiclesList, { - model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), - plate = vehicles[i].plate, - props = vehicles[i].vehicle - }) - - end - - local spawnPoint = { - x = v.SpawnPoint.x, - y = v.SpawnPoint.y, - z = v.SpawnPoint.z, - heading = v.SpawnPoint.heading - } - - ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', - function(vehicles) - if next(vehicles) ~= nil then - - for i = 1, #vehicles, 1 do - table.insert(vehiclesImpoundedList, { - model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), - plate = vehicles[i].plate, - props = vehicles[i].vehicle - }) - end - - local poundSpawnPoint = { - x = Config.Pounds[v.ImpoundedName].GetOutPoint.x, - y = Config.Pounds[v.ImpoundedName].GetOutPoint.y, - } - - SendNUIMessage({ - showMenu = true, - type = 'garage', - vehiclesList = { - json.encode(vehiclesList) - }, - vehiclesImpoundedList = { - json.encode(vehiclesImpoundedList) - }, - poundName = v.ImpoundedName, - poundSpawnPoint = poundSpawnPoint, - spawnPoint = spawnPoint, - locales = { - action = _U('veh_exit'), - veh_model = _U('veh_model'), - veh_plate = _U('veh_plate'), - veh_condition = _U('veh_condition'), - veh_action = _U('veh_action'), - impound_action = _U('impound_action'), - } - }) - else - SendNUIMessage({ - showMenu = true, - type = 'garage', - vehiclesList = { - json.encode(vehiclesList) - }, - spawnPoint = spawnPoint, - locales = { - action = _U('veh_exit'), - veh_model = _U('veh_model'), - veh_plate = _U('veh_plate'), - veh_condition = _U('veh_condition'), - veh_action = _U('veh_action'), - no_veh_impounded = _U('no_veh_impounded'), - } - }) - end - end) - - SetNuiFocus(true, true) - - if menuIsShowed then - ESX.HideUI() - end - else - menuIsShowed = true - - ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', - function(vehicles) - if next(vehicles) ~= nil then - - for i = 1, #vehicles, 1 do - table.insert(vehiclesImpoundedList, { - model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), - plate = vehicles[i].plate, - props = vehicles[i].vehicle - }) - end - - local poundSpawnPoint = { - x = Config.Pounds[v.ImpoundedName].GetOutPoint.x, - y = Config.Pounds[v.ImpoundedName].GetOutPoint.y, - } - - SendNUIMessage({ - showMenu = true, - type = 'garage', - vehiclesImpoundedList = { - json.encode(vehiclesImpoundedList) - }, - poundName = v.ImpoundedName, - poundSpawnPoint = poundSpawnPoint, - locales = { - action = _U('veh_exit'), - veh_model = _U('veh_model'), - veh_plate = _U('veh_plate'), - veh_condition = _U('veh_condition'), - veh_action = _U('veh_action'), - no_veh_parking = _U('no_veh_parking'), - no_veh_impounded = _U('no_veh_impounded'), - impound_action = _U('impound_action'), - } - }) - else - SendNUIMessage({ - showMenu = true, - type = 'garage', - locales = { - action = _U('veh_exit'), - veh_model = _U('veh_model'), - veh_plate = _U('veh_plate'), - veh_condition = _U('veh_condition'), - veh_action = _U('veh_action'), - no_veh_parking = _U('no_veh_parking') - } - }) - end - end) - - - SetNuiFocus(true, true) - - if menuIsShowed then - ESX.HideUI() - end - - -- ESX.ShowNotification(_U('no_veh_parking')) - end - end, currentMarker) - end - break - end - - if (#(coords - vector3(v.StorePoint.x, v.StorePoint.y, v.StorePoint.z)) < Config.Markers.StorePoint.Size.x) then - isInMarker = true - currentMarker = k - currentPart = 'StorePoint' local isInVehicle = IsPedInAnyVehicle(playerPed, false) + if not isInVehicle then + if IsControlJustReleased(0, 38) and not menuIsShowed then + ESX.TriggerServerCallback('esx_garage:getVehiclesInParking', + function(vehicles) + if next(vehicles) ~= nil then + menuIsShowed = true + + for i = 1, #vehicles, 1 do + table.insert(vehiclesList, { + model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), + plate = vehicles[i].plate, + props = vehicles[i].vehicle + }) + + end + + local spawnPoint = { + x = v.SpawnPoint.x, + y = v.SpawnPoint.y, + z = v.SpawnPoint.z, + heading = v.SpawnPoint.heading + } + + ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', + function(vehicles) + if next(vehicles) ~= nil then + + for i = 1, #vehicles, 1 do + table.insert(vehiclesImpoundedList, { + model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), + plate = vehicles[i].plate, + props = vehicles[i].vehicle + }) + end + + local poundSpawnPoint = { + x = Config.Pounds[v.ImpoundedName].GetOutPoint.x, + y = Config.Pounds[v.ImpoundedName].GetOutPoint.y, + } + + SendNUIMessage({ + showMenu = true, + type = 'garage', + vehiclesList = { + json.encode(vehiclesList) + }, + vehiclesImpoundedList = { + json.encode(vehiclesImpoundedList) + }, + poundName = v.ImpoundedName, + poundSpawnPoint = poundSpawnPoint, + spawnPoint = spawnPoint, + locales = { + action = _U('veh_exit'), + veh_model = _U('veh_model'), + veh_plate = _U('veh_plate'), + veh_condition = _U('veh_condition'), + veh_action = _U('veh_action'), + impound_action = _U('impound_action'), + } + }) + else + SendNUIMessage({ + showMenu = true, + type = 'garage', + vehiclesList = { + json.encode(vehiclesList) + }, + spawnPoint = spawnPoint, + locales = { + action = _U('veh_exit'), + veh_model = _U('veh_model'), + veh_plate = _U('veh_plate'), + veh_condition = _U('veh_condition'), + veh_action = _U('veh_action'), + no_veh_impounded = _U('no_veh_impounded'), + } + }) + end + end) + + SetNuiFocus(true, true) + + if menuIsShowed then + ESX.HideUI() + end + else + menuIsShowed = true + + ESX.TriggerServerCallback('esx_garage:getVehiclesImpounded', + function(vehicles) + if next(vehicles) ~= nil then + + for i = 1, #vehicles, 1 do + table.insert(vehiclesImpoundedList, { + model = GetDisplayNameFromVehicleModel(vehicles[i].vehicle.model), + plate = vehicles[i].plate, + props = vehicles[i].vehicle + }) + end + + local poundSpawnPoint = { + x = Config.Pounds[v.ImpoundedName].GetOutPoint.x, + y = Config.Pounds[v.ImpoundedName].GetOutPoint.y, + } + + SendNUIMessage({ + showMenu = true, + type = 'garage', + vehiclesImpoundedList = { + json.encode(vehiclesImpoundedList) + }, + poundName = v.ImpoundedName, + poundSpawnPoint = poundSpawnPoint, + locales = { + action = _U('veh_exit'), + veh_model = _U('veh_model'), + veh_plate = _U('veh_plate'), + veh_condition = _U('veh_condition'), + veh_action = _U('veh_action'), + no_veh_parking = _U('no_veh_parking'), + no_veh_impounded = _U('no_veh_impounded'), + impound_action = _U('impound_action'), + } + }) + else + SendNUIMessage({ + showMenu = true, + type = 'garage', + locales = { + action = _U('veh_exit'), + veh_model = _U('veh_model'), + veh_plate = _U('veh_plate'), + veh_condition = _U('veh_condition'), + veh_action = _U('veh_action'), + no_veh_parking = _U('no_veh_parking') + } + }) + end + end) + + + SetNuiFocus(true, true) + + if menuIsShowed then + ESX.HideUI() + end + end + end, currentMarker) + end + end + if isInVehicle then if IsControlJustReleased(0, 38) then local vehicle = GetVehiclePedIsIn(playerPed, false) @@ -393,6 +375,7 @@ CreateThread(function() end, vehicleProps.plate) end end + break end end diff --git a/[esx_addons]/esx_garage/config.lua b/[esx_addons]/esx_garage/config.lua index adf58af7..c5c807a9 100644 --- a/[esx_addons]/esx_garage/config.lua +++ b/[esx_addons]/esx_garage/config.lua @@ -25,12 +25,12 @@ Config.Markers = { z = 1.0 }, Color = { - r = 0, - g = 153, - b = 51, + r = 54, + g = 51, + b = 255, } }, - StorePoint = { + GetOutPoint = { Type = 1, Size = { x = 2.0, @@ -43,19 +43,6 @@ Config.Markers = { b = 51, } }, - GetOutPoint = { - Type = 1, - Size = { - x = 2.0, - y = 2.0, - z = 1.0 - }, - Color = { - r = 54, - g = 51, - b = 255, - } - }, } Config.Garages = { @@ -65,11 +52,6 @@ Config.Garages = { y = -886.5, z = 30.0 }, - StorePoint = { - x = -298.8, - y = -901.0, - z = 30.0 - }, SpawnPoint = { x = -309.3, y = -897.0, @@ -84,11 +66,6 @@ Config.Garages = { y = -786.6, z = 29.8, }, - StorePoint = { - x = 231.9, - y = -792.9, - z = 29.5 - }, SpawnPoint = { x = 218.9, y = -779.7, diff --git a/[esx_addons]/esx_garage/nui/js/app.js b/[esx_addons]/esx_garage/nui/js/app.js index 43e632ca..fd5e8855 100644 --- a/[esx_addons]/esx_garage/nui/js/app.js +++ b/[esx_addons]/esx_garage/nui/js/app.js @@ -17,7 +17,12 @@ $(window).ready(function () { $("#container").data("spawnpoint", data.spawnPoint); if (data.poundCost) $("#container").data("poundcost", data.poundCost); - $(".content .vehicle-list").html(getVehicles(data.locales, data.vehiclesList)); + if (data.poundCost != undefined) { + $(".content .vehicle-list").html(getVehicles(data.locales, data.vehiclesList, data.poundCost)); + } else { + $(".content .vehicle-list").html(getVehicles(data.locales, data.vehiclesList)); + } + $('.content h2').hide(); } else { $('.content h2').show(); @@ -85,7 +90,7 @@ $(window).ready(function () { } }; -function getVehicles(locale, vehicle) { +function getVehicles(locale, vehicle, amount = null) { let html = ""; let vehicleData = JSON.parse(vehicle); let bodyHealth = 1000; @@ -111,7 +116,7 @@ function getVehicles(locale, vehicle) { ""; html += ""; }