diff --git a/server-data/resources/[esx_addons]/esx_vehicleshop/client/main.lua b/server-data/resources/[esx_addons]/esx_vehicleshop/client/main.lua index 0265cdaf3..10f424736 100644 --- a/server-data/resources/[esx_addons]/esx_vehicleshop/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_vehicleshop/client/main.lua @@ -1,8 +1,19 @@ local Config = Config local HasAlreadyEnteredMarker, IsInShopMenu = false, false local CurrentAction, CurrentActionMsg, LastZone, currentDisplayVehicle, CurrentVehicleData -local CurrentActionData, Vehicles, Categories, VehiclesByModel, vehiclesByCategory, soldVehicles, cardealerVehicles, rentedVehicles = {}, {}, {}, {}, {}, {}, {}, {} -local DoesEntityExist, NetworkRequestControlOfEntity, NetworkHasControlOfEntity, DisableControlAction, HasModelLoaded, RequestModel, DisableAllControlActions, FreezeEntityPosition, SetEntityCoords, SetEntityVisible = DoesEntityExist, NetworkRequestControlOfEntity, NetworkHasControlOfEntity, DisableControlAction, HasModelLoaded, RequestModel, DisableAllControlActions, FreezeEntityPosition, SetEntityCoords, SetEntityVisible +local CurrentActionData, Vehicles, Categories, VehiclesByModel, vehiclesByCategory, soldVehicles, cardealerVehicles, rentedVehicles = + {}, {}, {}, {}, {}, {}, {}, {} +local DoesEntityExist, NetworkRequestControlOfEntity, NetworkHasControlOfEntity, DisableControlAction, HasModelLoaded, RequestModel, DisableAllControlActions, FreezeEntityPosition, SetEntityCoords, SetEntityVisible = + DoesEntityExist, + NetworkRequestControlOfEntity, + NetworkHasControlOfEntity, + DisableControlAction, + HasModelLoaded, + RequestModel, + DisableAllControlActions, + FreezeEntityPosition, + SetEntityCoords, + SetEntityVisible Vehicles = GlobalState.vehicleShop.vehicles Categories = GlobalState.vehicleShop.categories @@ -11,20 +22,20 @@ soldVehicles = GlobalState.vehicleShop.soldVehicles cardealerVehicles = GlobalState.vehicleShop.cardealerVehicles rentedVehicles = GlobalState.vehicleShop.rentedVehicles -AddStateBagChangeHandler('vehicleShop', 'global', function(bagName, key, value) - Vehicles = value.vehicles - Categories = value.categories - VehiclesByModel = value.vehiclesByModel - soldVehicles = value.soldVehicles - cardealerVehicles = value.cardealerVehicles - rentedVehicles = value.rentedVehicles +AddStateBagChangeHandler("vehicleShop", "global", function(bagName, key, value) + Vehicles = value.vehicles + Categories = value.categories + VehiclesByModel = value.vehiclesByModel + soldVehicles = value.soldVehicles + cardealerVehicles = value.cardealerVehicles + rentedVehicles = value.rentedVehicles end) CreateThread(function() - while true do - Wait(60000) - collectgarbage("collect") - end + while true do + Wait(60000) + collectgarbage("collect") + end end) local function getVehicleFromModel(model) @@ -32,7 +43,7 @@ local function getVehicleFromModel(model) end local function Init() - TriggerEvent('esx_vehicleshop:updateTables') + TriggerEvent("esx_vehicleshop:updateTables") Wait(500) @@ -51,20 +62,25 @@ local function Init() table.insert(vehiclesByCategory[category], vehicle) else - print(('[^3WARNING^7] Ignoring vehicle ^5%s^7 due to invalid Model'):format(vehicle.model)) + print(("[^3WARNING^7] Ignoring vehicle ^5%s^7 due to invalid Model"):format(vehicle.model)) end end if Config.EnablePlayerManagement then - RegisterNetEvent('esx_phone:loaded') - AddEventHandler('esx_phone:loaded', function(phoneNumber, contacts) + RegisterNetEvent("esx_phone:loaded") + AddEventHandler("esx_phone:loaded", function(phoneNumber, contacts) local specialContact = { - name = TranslateCap('dealership'), - number = 'cardealer', - base64Icon = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAMAAABrrFhUAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAMAUExURQAAADMzMzszM0M0M0w0M1Q1M101M2U2M242M3Y3M383Moc4MpA4Mpg5MqE5Mqk6MrI6Mro7Mrw8Mr89M71DML5EO8I+NMU/NcBMLshANctBNs5CN8RULMddKsheKs9YLtBCONZEOdlFOtxGO99HPNhMNsplKM1nKM1uJtRhLddiLt5kMNJwJ9B2JNR/IeNIPeVJPehKPuRQOuhSO+lZOOlhNuloM+p3Lep/KupwMMFORsVYUcplXc1waNJ7delUSepgVexrYe12bdeHH9iIH9qQHd2YG+udH+OEJeuGJ+uOJeuVIuChGeSpF+aqGOykHOysGeeyFeuzFuyzFuq6E+27FO+Cee3CEdaGgdqTjvCNhfKYkvOkngAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJezdycAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGHRFWHRTb2Z0d2FyZQBwYWludC5uZXQgNC4xLjb9TgnoAAAQGElEQVR4Xt2d+WMUtxXHbS6bEGMPMcQQ04aEUnqYo9xJWvC6kAKmQLM2rdn//9+g0uir2Tl0PElPszP7+cnH7Fj6r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AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAJezdycAAAEAdFJOU////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////wBT9wclAAAACXBIWXMAAA7DAAAOwwHHb6hkAAAAGHRFWHRTb2Z0d2FyZQBwYWludC5uZXQgNC4xLjb9TgnoAAAQGElEQVR4Xt2d+WMUtxXHbS6bEGMPMcQQ04aEUnqYo9xJWvC6kAKmQLM2rdn//9+g0uir2Tl0PElPszP7+cnH7Fj6rPTeG2lmvfKld2azk8lk/36L/cnkZDbDIT3Sp4DZ8QS9dTI57tNDTwJOOu+4j/0TvDQz+QXMSG+7mUn+sZBZQELnNROcKhMZBXx+gS4k8+IzTpmBXAJOnqPxTDzPFRKyCODuvSKPgwwC2EZ+lxf4E4xwCzhBU7PBPQx4BWR88+fwDgNGAbMsM9/Ec8bygE3A5966L3nOlhiZBGSf+l2YggGLgBna1DMsE4FBQH9zvw1HLEgX0Evkt5GeEVIFMFztpJF6rZQm4DNasVDSEkKSgIVN/ibP0ZwoEgQsfPTPSZgH8QIG8vYr4gdBrIABvf2K2EEQKWBQb78ichBECRhE8O8SlQ5iBAQvcffFPhoYQoSAAQ5/TcQ0CBYw0OGvCZ4GoQIGF/3bhGaDQAELvfKhERgIwgQMePrPCQsEQQLwFwYPmksiQMCC1n1iCFgooQtYwLJfPPQFQ7KAUfU/wABVwMj6TzdAFDDY6tcOMR3SBIyw/1QDJAGj7D/RAEXA6Oa/hhIHCAJG23+SAb+AEfefYsArYET1nwlvTegVgBONFnTDik8ATjNi0BEbHgGjuP5147k6dgsYaQHQxF0OOAUMfv2LhnOVzCVg4OufdFwrpS4BePkS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VspKMgYBU/tUIFZC+UlqSLRC41j+NBAsYdCAIm/4lEQKGGwgCp39JjACmacAeCIKHvyRKANM04A0EEcNfEimAKRswBoK/o2GhxApgGgRcgSDy7RfEC+AZBDyBIDT510gQwDMIGAJB/NsvSBLAkw5SA0FU8K9IE8AzD5ICQcLoL0kVEP2ERR3zZzRR6Dz/EEy6gC+z9FBwL24D9XLAwocNBgEsa0URj11xdJ9JAMeCYfBjV/RlPydMAkRCSJ0IQYGA592XsAlIjwX0QMDXfVYBgsSMQAsE6ZG/Dq+A1GBACARMU7+CW4AgZRh4AgHvm1+SQYAYBvHRwBEILnO/+SVZBAjiHZgDQZ7eC3IJEHyOnAvdQPBT2vWOk4wCJFHXSs1AkHq14yGzAMEsXEIVCH5hTPgW8gsoOQlcSr9W/Jxr0rfoSUDJ7Jg0GCbHM7ygD/oUAGazk8mkMyL2J5OTWZ89L/ny5f+yiDXCPYKoAQAAAABJRU5ErkJggg==", } - TriggerEvent('esx_phone:addSpecialContact', specialContact.name, specialContact.number, specialContact.base64Icon) + TriggerEvent( + "esx_phone:addSpecialContact", + specialContact.name, + specialContact.number, + specialContact.base64Icon + ) end) end @@ -72,13 +88,13 @@ local function Init() CreateThread(function() local blip = AddBlipForCoord(Config.Zones.ShopEntering.Pos) - SetBlipSprite (blip, Config.Blip.Sprite) + SetBlipSprite(blip, Config.Blip.Sprite) SetBlipDisplay(blip, Config.Blip.Display) - SetBlipScale (blip, Config.Blip.Scale) + SetBlipScale(blip, Config.Blip.Scale) SetBlipAsShortRange(blip, true) - BeginTextCommandSetBlipName('STRING') - AddTextComponentSubstringPlayerName(TranslateCap('car_dealer')) + BeginTextCommandSetBlipName("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("car_dealer")) EndTextCommandSetBlipName(blip) end) end @@ -91,43 +107,47 @@ local function PlayerManagement() return true end - if LocalPlayer.state.job ~= 'cardealer' then + if LocalPlayer.state.job ~= "cardealer" then Config.Zones.ShopEntering.Type = -1 - Config.Zones.BossActions.Type = -1 + Config.Zones.BossActions.Type = -1 Config.Zones.ResellVehicle.Type = -1 return true end Config.Zones.ShopEntering.Type = 1 - if LocalPlayer.state.job.grade_name == 'boss' then + if LocalPlayer.state.job.grade_name == "boss" then Config.Zones.BossActions.Type = 1 end return true end local function loadIpl() - RequestIpl('shr_int') + RequestIpl("shr_int") local interiorID = 7170 PinInteriorInMemory(interiorID) - ActivateInteriorEntitySet(interiorID, 'csr_beforeMission') + ActivateInteriorEntitySet(interiorID, "csr_beforeMission") RefreshInterior(interiorID) end -RegisterNetEvent('esx:playerLoaded') -AddEventHandler('esx:playerLoaded', function(xPlayer) +RegisterNetEvent("esx:playerLoaded") +AddEventHandler("esx:playerLoaded", function(xPlayer) Init() PlayerManagement() CreateThread(loadIpl) end) -RegisterNetEvent('esx:setJob', PlayerManagement) +RegisterNetEvent("esx:setJob", PlayerManagement) local function DeleteDisplayVehicleInsideShop() local attempt = 0 if currentDisplayVehicle and DoesEntityExist(currentDisplayVehicle) then - while DoesEntityExist(currentDisplayVehicle) and not NetworkHasControlOfEntity(currentDisplayVehicle) and attempt < 100 do + while + DoesEntityExist(currentDisplayVehicle) + and not NetworkHasControlOfEntity(currentDisplayVehicle) + and attempt < 100 + do Wait(100) NetworkRequestControlOfEntity(currentDisplayVehicle) attempt = attempt + 1 @@ -144,7 +164,7 @@ local function ReturnVehicleProvider() { unselectable = true, icon = "fas fa-car", - title = TranslateCap('car_dealer'), + title = TranslateCap("car_dealer"), }, } @@ -153,38 +173,42 @@ local function ReturnVehicleProvider() local vehicleLabel = getVehicleFromModel(v.vehicle).label TableInsert(elements, { - title = ('%s [%s]'):format(vehicleLabel, TranslateCap('generic_shopitem', ESX.Math.GroupDigits(returnPrice))), - name = v.vehicle + title = ('%s [%s]'):format( + vehicleLabel, + TranslateCap("generic_shopitem", ESX.Math.GroupDigits(returnPrice)) + ), + name = v.vehicle, }) end ESX.OpenContext("right", elements, function(menu, element) - if not element.name then return ESX.CloseContext() end - TriggerServerEvent('esx_vehicleshop:returnProvider', element.name) + if not element.name then + return ESX.CloseContext() + end + TriggerServerEvent("esx_vehicleshop:returnProvider", element.name) Wait(500) ESX.CloseContext() ReturnVehicleProvider() - end, function(menu) - end) + end, function(menu) end) end local function StartShopRestriction() while IsInShopMenu do Wait(0) - DisableControlAction(0, 75, true) -- Disable exit vehicle + DisableControlAction(0, 75, true) -- Disable exit vehicle DisableControlAction(27, 75, true) -- Disable exit vehicle end end local function WaitForVehicleToLoad(modelHash) - modelHash = (type(modelHash) == 'number' and modelHash or joaat(modelHash)) + modelHash = (type(modelHash) == "number" and modelHash or joaat(modelHash)) if not HasModelLoaded(modelHash) then RequestModel(modelHash) - BeginTextCommandBusyspinnerOn('STRING') - AddTextComponentSubstringPlayerName(TranslateCap('shop_awaiting_model')) + BeginTextCommandBusyspinnerOn("STRING") + AddTextComponentSubstringPlayerName(TranslateCap("shop_awaiting_model")) EndTextCommandBusyspinnerOn(4) while not HasModelLoaded(modelHash) do @@ -198,7 +222,7 @@ end local function OpenShopMenu() if #Vehicles == 0 then - print('[^3ERROR^7] Vehicleshop has ^50^7 vehicles, please add some!') + print("[^3ERROR^7] Vehicleshop has ^50^7 vehicles, please add some!") return end @@ -214,59 +238,66 @@ local function OpenShopMenu() SetEntityVisible(playerPed, false) SetEntityCoords(playerPed, Config.Zones.ShopInside.Pos) - local elements = {} - local firstVehicleData = nil + local elements = {} + local firstVehicleData = nil - for i=1, #Categories, 1 do - local category = Categories[i] + for i = 1, #Categories, 1 do + local category = Categories[i] local categoryVehicles = vehiclesByCategory[category.name] - local options = {} + local options = {} - for j=1, #categoryVehicles, 1 do + for j = 1, #categoryVehicles, 1 do local vehicle = categoryVehicles[j] if i == 1 and j == 1 then firstVehicleData = vehicle end - TableInsert(options, ('%s %s'):format(vehicle.name, TranslateCap('generic_shopitem', ESX.Math.GroupDigits(vehicle.price)))) + TableInsert( + options, + ('%s %s'):format( + vehicle.name, + TranslateCap("generic_shopitem", ESX.Math.GroupDigits(vehicle.price)) + ) + ) end table.sort(options) TableInsert(elements, { - name = category.name, - label = category.label, - value = 0, - type = 'slider', - max = #Categories[i], - options = options + name = category.name, + label = category.label, + value = 0, + type = "slider", + max = #Categories[i], + options = options, }) end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'vehicle_shop', { - title = TranslateCap('car_dealer'), - align = 'top-left', - elements = elements + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "vehicle_shop", { + title = TranslateCap("car_dealer"), + align = "top-left", + elements = elements, }, function(data, menu) local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1] - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_confirm', { - title = TranslateCap('buy_vehicle_shop', vehicleData.name, ESX.Math.GroupDigits(vehicleData.price)), - align = 'top-left', + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "shop_confirm", { + title = TranslateCap("buy_vehicle_shop", vehicleData.name, ESX.Math.GroupDigits(vehicleData.price)), + align = "top-left", elements = { - {label = TranslateCap('no'), value = 'no'}, - {label = TranslateCap('yes'), value = 'yes'} - }}, function(data2, menu2) - if data2.current.value == 'yes' then + { label = TranslateCap("no"), value = "no" }, + { label = TranslateCap("yes"), value = "yes" }, + }, + }, function(data2, menu2) + if data2.current.value == "yes" then if Config.EnablePlayerManagement then - ESX.TriggerServerCallback('esx_vehicleshop:buyCarDealerVehicle', function(success) + ESX.TriggerServerCallback("esx_vehicleshop:buyCarDealerVehicle", function(success) if success then IsInShopMenu = false DeleteDisplayVehicleInsideShop() - CurrentAction = 'shop_menu' - CurrentActionMsg = TranslateCap('shop_menu') + CurrentAction = "shop_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} local playerPed = ESX.PlayerData.ped @@ -276,15 +307,15 @@ local function OpenShopMenu() menu2.close() menu.close() - ESX.ShowNotification(TranslateCap('vehicle_purchased')) + ESX.ShowNotification(TranslateCap("vehicle_purchased")) else - ESX.ShowNotification(TranslateCap('broke_company')) + ESX.ShowNotification(TranslateCap("broke_company")) end end, vehicleData.model) else local generatedPlate = GeneratePlate() - ESX.TriggerServerCallback('esx_vehicleshop:buyVehicle', function(success) + ESX.TriggerServerCallback("esx_vehicleshop:buyVehicle", function(success) if success then IsInShopMenu = false menu2.close() @@ -293,7 +324,7 @@ local function OpenShopMenu() FreezeEntityPosition(playerPed, false) SetEntityVisible(playerPed, true) else - ESX.ShowNotification(TranslateCap('not_enough_money')) + ESX.ShowNotification(TranslateCap("not_enough_money")) end end, vehicleData.model, generatedPlate) end @@ -308,8 +339,8 @@ local function OpenShopMenu() DeleteDisplayVehicleInsideShop() local playerPed = ESX.PlayerData.ped - CurrentAction = 'shop_menu' - CurrentActionMsg = TranslateCap('shop_menu') + CurrentAction = "shop_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} FreezeEntityPosition(playerPed, false) @@ -319,28 +350,38 @@ local function OpenShopMenu() IsInShopMenu = false end, function(data, menu) local vehicleData = vehiclesByCategory[data.current.name][data.current.value + 1] - local playerPed = ESX.PlayerData.ped + local playerPed = ESX.PlayerData.ped DeleteDisplayVehicleInsideShop() WaitForVehicleToLoad(vehicleData.model) - ESX.Game.SpawnLocalVehicle(vehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function(vehicle) - currentDisplayVehicle = vehicle - TaskWarpPedIntoVehicle(playerPed, vehicle, -1) - FreezeEntityPosition(vehicle, true) - SetModelAsNoLongerNeeded(vehicleData.model) - end) + ESX.Game.SpawnLocalVehicle( + vehicleData.model, + Config.Zones.ShopInside.Pos, + Config.Zones.ShopInside.Heading, + function(vehicle) + currentDisplayVehicle = vehicle + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + FreezeEntityPosition(vehicle, true) + SetModelAsNoLongerNeeded(vehicleData.model) + end + ) end) DeleteDisplayVehicleInsideShop() WaitForVehicleToLoad(firstVehicleData.model) - ESX.Game.SpawnLocalVehicle(firstVehicleData.model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function(vehicle) - currentDisplayVehicle = vehicle - TaskWarpPedIntoVehicle(playerPed, vehicle, -1) - FreezeEntityPosition(vehicle, true) - SetModelAsNoLongerNeeded(firstVehicleData.model) - end) + ESX.Game.SpawnLocalVehicle( + firstVehicleData.model, + Config.Zones.ShopInside.Pos, + Config.Zones.ShopInside.Heading, + function(vehicle) + currentDisplayVehicle = vehicle + TaskWarpPedIntoVehicle(playerPed, vehicle, -1) + FreezeEntityPosition(vehicle, true) + SetModelAsNoLongerNeeded(firstVehicleData.model) + end + ) end function OpenResellerMenu() @@ -348,64 +389,84 @@ function OpenResellerMenu() ESX.CloseContext() local elements = { - {unselectable = true, icon = 'fas fa-car', title = TranslateCap('car_dealer')}, - {title = TranslateCap('buy_vehicle'), name = 'buy_vehicle'}, - {title = TranslateCap('pop_vehicle'), name = 'pop_vehicle'}, - {title = TranslateCap('depop_vehicle'), name = 'depop_vehicle'}, - {title = TranslateCap('return_provider'), name = 'return_provider'}, - {title = TranslateCap('create_bill'), name = 'create_bill'}, - {title = TranslateCap('get_rented_vehicles'), name = 'get_rented_vehicles'}, - {title = TranslateCap('set_vehicle_owner_sell'), name = 'set_vehicle_owner_sell'}, - {title = TranslateCap('set_vehicle_owner_rent'), name = 'set_vehicle_owner_rent'}, - {title = TranslateCap('deposit_stock'), name = 'put_stock'}, - {title = TranslateCap('take_stock'), name = 'get_stock'}, + { unselectable = true, icon = "fas fa-car", title = TranslateCap("car_dealer") }, + { title = TranslateCap("buy_vehicle"), name = "buy_vehicle" }, + { title = TranslateCap("pop_vehicle"), name = "pop_vehicle" }, + { title = TranslateCap("depop_vehicle"), name = "depop_vehicle" }, + { title = TranslateCap("return_provider"), name = "return_provider" }, + { title = TranslateCap("create_bill"), name = "create_bill" }, + { title = TranslateCap("get_rented_vehicles"), name = "get_rented_vehicles" }, + { title = TranslateCap("set_vehicle_owner_sell"), name = "set_vehicle_owner_sell" }, + { title = TranslateCap("set_vehicle_owner_rent"), name = "set_vehicle_owner_rent" }, + { title = TranslateCap("deposit_stock"), name = "put_stock" }, + { title = TranslateCap("take_stock"), name = "get_stock" }, } - ESX.OpenContext('right', elements, function(menu, element) + ESX.OpenContext("right", elements, function(menu, element) local action = element.name - if Config.OxInventory and (action == 'put_stock' or action == 'get_stock') then - exports.ox_inventory:openInventory('stash', 'society_cardealer') - elseif action == 'buy_vehicle' then + if Config.OxInventory and (action == "put_stock" or action == "get_stock") then + exports.ox_inventory:openInventory("stash", "society_cardealer") + elseif action == "buy_vehicle" then OpenShopMenu() - elseif action == 'put_stock' then + elseif action == "put_stock" then OpenPutStocksMenu() - elseif action == 'get_stock' then + elseif action == "get_stock" then OpenGetStocksMenu() - elseif action == 'pop_vehicle' then + elseif action == "pop_vehicle" then OpenPopVehicleMenu() - elseif action == 'depop_vehicle' then + elseif action == "depop_vehicle" then if currentDisplayVehicle then DeleteDisplayVehicleInsideShop() else - ESX.ShowNotification(TranslateCap('no_current_vehicle')) + ESX.ShowNotification(TranslateCap("no_current_vehicle")) end - elseif action == 'return_provider' then + elseif action == "return_provider" then ReturnVehicleProvider() - elseif action == 'create_bill' then + elseif action == "create_bill" then local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer ~= -1 and closestDistance < 3 then ESX.CloseContext() - ESX.OpenContext('right', {{title = TranslateCap('invoice_amount'), input = true, inputType = 'number', inputValue = 0, inputMin = 0, name = 'invoice_amount'}}, function(menu2, element2) - if element2.name == 'invoice_amount' then - local amount = tonumber(element2.inputValue) - if amount ~= nil then - ESX.CloseContext() - local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() - if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(TranslateCap('no_players')) - else - TriggerServerEvent('esx_billing:sendBill', GetPlayerServerId(closestPlayer), 'society_cardealer', TranslateCap('car_dealer'), amount) + ESX.OpenContext( + "right", + { + { + title = TranslateCap("invoice_amount"), + input = true, + inputType = "number", + inputValue = 0, + inputMin = 0, + name = "invoice_amount", + }, + }, + function(menu2, element2) + if element2.name == "invoice_amount" then + local amount = tonumber(element2.inputValue) + if amount ~= nil then + ESX.CloseContext() + local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() + if closestPlayer == -1 or closestDistance > 3.0 then + ESX.ShowNotification(TranslateCap("no_players")) + else + TriggerServerEvent( + "esx_billing:sendBill", + GetPlayerServerId(closestPlayer), + "society_cardealer", + TranslateCap("car_dealer"), + amount + ) + end end end - end - end, function(menu) end) + end, + function(menu) end + ) else - ESX.ShowNotification(TranslateCap('no_players')) + ESX.ShowNotification(TranslateCap("no_players")) end - elseif action == 'get_rented_vehicles' then + elseif action == "get_rented_vehicles" then OpenRentedVehiclesMenu() - elseif action == 'set_vehicle_owner_sell' then + elseif action == "set_vehicle_owner_sell" then if currentDisplayVehicle then local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() @@ -414,53 +475,65 @@ function OpenResellerMenu() local vehicleProps = ESX.Game.GetVehicleProperties(currentDisplayVehicle) vehicleProps.plate = newPlate SetVehicleNumberPlateText(currentDisplayVehicle, newPlate) - TriggerServerEvent('esx_vehicleshop:setVehicleOwnedPlayerId', GetPlayerServerId(closestPlayer), vehicleProps, CurrentVehicleData.model, CurrentVehicleData.name) + TriggerServerEvent( + "esx_vehicleshop:setVehicleOwnedPlayerId", + GetPlayerServerId(closestPlayer), + vehicleProps, + CurrentVehicleData.model, + CurrentVehicleData.name + ) currentDisplayVehicle = nil else - ESX.ShowNotification(TranslateCap('no_players')) + ESX.ShowNotification(TranslateCap("no_players")) end else - ESX.ShowNotification(TranslateCap('no_current_vehicle')) + ESX.ShowNotification(TranslateCap("no_current_vehicle")) end - elseif action == 'set_vehicle_owner_rent' then + elseif action == "set_vehicle_owner_rent" then if currentDisplayVehicle then local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer ~= -1 and closestDistance < 3 then - ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'set_vehicle_owner_rent_amount', { - title = TranslateCap('rental_amount') + ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "set_vehicle_owner_rent_amount", { + title = TranslateCap("rental_amount"), }, function(data2, menu2) local amount = tonumber(data2.value) if not amount then - ESX.ShowNotification(TranslateCap('invalid_amount')) + ESX.ShowNotification(TranslateCap("invalid_amount")) else menu2.close() local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer ~= -1 and closestDistance < 3 then - local newPlate = 'RENT' .. string.upper(ESX.GetRandomString(4)) + local newPlate = "RENT" .. string.upper(ESX.GetRandomString(4)) local model = CurrentVehicleData.model SetVehicleNumberPlateText(currentDisplayVehicle, newPlate) - TriggerServerEvent('esx_vehicleshop:rentVehicle', model, newPlate, amount, GetPlayerServerId(closestPlayer)) + TriggerServerEvent( + "esx_vehicleshop:rentVehicle", + model, + newPlate, + amount, + GetPlayerServerId(closestPlayer) + ) currentDisplayVehicle = nil else - ESX.ShowNotification(TranslateCap('no_players')) + ESX.ShowNotification(TranslateCap("no_players")) end end end, function(data2, menu2) menu2.close() end) else - ESX.ShowNotification(TranslateCap('no_players')) + ESX.ShowNotification(TranslateCap("no_players")) end else - ESX.ShowNotification(TranslateCap('no_current_vehicle')) + ESX.ShowNotification(TranslateCap("no_current_vehicle")) end end end, function(menu) - CurrentAction = 'reseller_menu' - CurrentActionMsg = TranslateCap('shop_menu') + CurrentAction = "reseller_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} end) end @@ -468,19 +541,22 @@ end function OpenPopVehicleMenu() local elements = {} - for k,v in ipairs(cardealerVehicles) do + for k, v in ipairs(cardealerVehicles) do local vehicleLabel = getVehicleFromModel(v.vehicle).label TableInsert(elements, { - label = ('%s [%s]'):format(vehicleLabel, TranslateCap('generic_shopitem', ESX.Math.GroupDigits(v.price))), - value = v.vehicle + label = ('%s [%s]'):format( + vehicleLabel, + TranslateCap("generic_shopitem", ESX.Math.GroupDigits(v.price)) + ), + value = v.vehicle, }) end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'commercial_vehicles', { - title = TranslateCap('vehicle_dealer'), - align = 'top-left', - elements = elements + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "commercial_vehicles", { + title = TranslateCap("vehicle_dealer"), + align = "top-left", + elements = elements, }, function(data, menu) local model = data.current.value DeleteDisplayVehicleInsideShop() @@ -488,7 +564,7 @@ function OpenPopVehicleMenu() ESX.Game.SpawnVehicle(model, Config.Zones.ShopInside.Pos, Config.Zones.ShopInside.Heading, function(vehicle) currentDisplayVehicle = vehicle - for i=1, #Vehicles, 1 do + for i = 1, #Vehicles, 1 do if model == Vehicles[i].model then CurrentVehicleData = Vehicles[i] break @@ -503,103 +579,120 @@ end function OpenRentedVehiclesMenu() local elements = {} - for k,v in ipairs(rentedVehicles) do + for k, v in ipairs(rentedVehicles) do local vehicleLabel = getVehicleFromModel(v.name).label TableInsert(elements, { label = ('%s: %s - %s'):format(v.playerName, vehicleLabel, v.plate), - value = v.name + value = v.name, }) end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'rented_vehicles', { - title = TranslateCap('rent_vehicle'), - align = 'top-left', - elements = elements - }, nil, function(data, menu) - menu.close() - end) + ESX.UI.Menu.Open( + "default", + GetCurrentResourceName(), + "rented_vehicles", + { + title = TranslateCap("rent_vehicle"), + align = "top-left", + elements = elements, + }, + nil, + function(data, menu) + menu.close() + end + ) end local function OpenBossActionsMenu() ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'reseller',{ - title = TranslateCap('dealer_boss'), - align = 'top-left', + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "reseller", { + title = TranslateCap("dealer_boss"), + align = "top-left", elements = { - {label = TranslateCap('boss_actions'), value = 'boss_actions'}, - {label = TranslateCap('boss_sold'), value = 'sold_vehicles'} - }}, function(data, menu) - if data.current.value == 'boss_actions' then - TriggerEvent('esx_society:openBossMenu', 'cardealer', function(data2, menu2) + { label = TranslateCap("boss_actions"), value = "boss_actions" }, + { label = TranslateCap("boss_sold"), value = "sold_vehicles" }, + }, + }, function(data, menu) + if data.current.value == "boss_actions" then + TriggerEvent("esx_society:openBossMenu", "cardealer", function(data2, menu2) menu2.close() end) - elseif data.current.value == 'sold_vehicles' then - - local elements = { - head = { TranslateCap('customer_client'), TranslateCap('customer_model'), TranslateCap('customer_plate'), TranslateCap('customer_soldby'), TranslateCap('customer_date') }, - rows = {} - } - - for i=1, #soldVehicles, 1 do - TableInsert(elements.rows, { - data = soldVehicles[i], - cols = { - soldVehicles[i].client, - soldVehicles[i].model, - soldVehicles[i].plate, - soldVehicles[i].soldby, - soldVehicles[i].date - } - }) - end + elseif data.current.value == "sold_vehicles" then + local elements = { + head = { + TranslateCap("customer_client"), + TranslateCap("customer_model"), + TranslateCap("customer_plate"), + TranslateCap("customer_soldby"), + TranslateCap("customer_date"), + }, + rows = {}, + } - ESX.UI.Menu.Open('list', GetCurrentResourceName(), 'sold_vehicles', elements, function(data2, menu2) + for i = 1, #soldVehicles, 1 do + TableInsert(elements.rows, { + data = soldVehicles[i], + cols = { + soldVehicles[i].client, + soldVehicles[i].model, + soldVehicles[i].plate, + soldVehicles[i].soldby, + soldVehicles[i].date, + }, + }) + end - end, function(data2, menu2) + ESX.UI.Menu.Open( + "list", + GetCurrentResourceName(), + "sold_vehicles", + elements, + function(data2, menu2) end, + function(data2, menu2) menu2.close() - end) + end + ) end - end, function(data, menu) menu.close() - CurrentAction = 'boss_actions_menu' - CurrentActionMsg = TranslateCap('shop_menu') + CurrentAction = "boss_actions_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} end) end function OpenGetStocksMenu() - ESX.TriggerServerCallback('esx_vehicleshop:getStockItems', function(items) + ESX.TriggerServerCallback("esx_vehicleshop:getStockItems", function(items) local elements = {} - for i=1, #items, 1 do + for i = 1, #items, 1 do if items[i].count > 0 then TableInsert(elements, { - label = 'x' .. items[i].count .. ' ' .. items[i].label, - value = items[i].name + label = "x" .. items[i].count .. " " .. items[i].label, + value = items[i].name, }) end end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', { - title = TranslateCap('dealership_stock'), - align = 'top-left', - elements = elements + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "stocks_menu", { + title = TranslateCap("dealership_stock"), + align = "top-left", + elements = elements, }, function(data, menu) local itemName = data.current.value - ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_get_item_count', { - title = TranslateCap('amount') + ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "stocks_menu_get_item_count", { + title = TranslateCap("amount"), }, function(data2, menu2) local count = tonumber(data2.value) if count == nil then - ESX.ShowNotification(TranslateCap('quantity_invalid')) + ESX.ShowNotification(TranslateCap("quantity_invalid")) else - TriggerServerEvent('esx_vehicleshop:getStockItem', itemName, count) + TriggerServerEvent("esx_vehicleshop:getStockItem", itemName, count) menu2.close() menu.close() OpenGetStocksMenu() @@ -614,37 +707,37 @@ function OpenGetStocksMenu() end function OpenPutStocksMenu() - ESX.TriggerServerCallback('esx_vehicleshop:getPlayerInventory', function(inventory) + ESX.TriggerServerCallback("esx_vehicleshop:getPlayerInventory", function(inventory) local elements = {} - for i=1, #inventory.items, 1 do + for i = 1, #inventory.items, 1 do local item = inventory.items[i] if item.count > 0 then TableInsert(elements, { - label = item.label .. ' x' .. item.count, - type = 'item_standard', - value = item.name + label = item.label .. " x" .. item.count, + type = "item_standard", + value = item.name, }) end end - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'stocks_menu', { - title = TranslateCap('inventory'), - align = 'top-left', - elements = elements + ESX.UI.Menu.Open("default", GetCurrentResourceName(), "stocks_menu", { + title = TranslateCap("inventory"), + align = "top-left", + elements = elements, }, function(data, menu) local itemName = data.current.value - ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'stocks_menu_put_item_count', { - title = TranslateCap('amount') + ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "stocks_menu_put_item_count", { + title = TranslateCap("amount"), }, function(data2, menu2) local count = tonumber(data2.value) if count == nil then - ESX.ShowNotification(TranslateCap('quantity_invalid')) + ESX.ShowNotification(TranslateCap("quantity_invalid")) else - TriggerServerEvent('esx_vehicleshop:putStockItems', itemName, count) + TriggerServerEvent("esx_vehicleshop:putStockItems", itemName, count) menu2.close() menu.close() OpenPutStocksMenu() @@ -659,28 +752,28 @@ function OpenPutStocksMenu() end local function hasEnteredMarker(zone) - if zone == 'ShopEntering' then + if zone == "ShopEntering" then if not Config.EnablePlayerManagement then - CurrentAction = 'shop_menu' - CurrentActionMsg = TranslateCap('shop_menu') + CurrentAction = "shop_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} end - if LocalPlayer.state.job ~= nil and LocalPlayer.state.job.name == 'cardealer' then - CurrentAction = 'reseller_menu' - CurrentActionMsg = TranslateCap('shop_menu') + if LocalPlayer.state.job ~= nil and LocalPlayer.state.job.name == "cardealer" then + CurrentAction = "reseller_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} end - elseif zone == 'GiveBackVehicle' and Config.EnablePlayerManagement then + elseif zone == "GiveBackVehicle" and Config.EnablePlayerManagement then local playerPed = ESX.PlayerData.ped if IsPedInAnyVehicle(playerPed, false) then local vehicle = GetVehiclePedIsIn(playerPed, false) - CurrentAction = 'give_back_vehicle' - CurrentActionMsg = TranslateCap('vehicle_menu') - CurrentActionData = {vehicle = vehicle} + CurrentAction = "give_back_vehicle" + CurrentActionMsg = TranslateCap("vehicle_menu") + CurrentActionData = { vehicle = vehicle } end - elseif zone == 'ResellVehicle' then + elseif zone == "ResellVehicle" then local playerPed = ESX.PlayerData.ped if IsPedSittingInAnyVehicle(playerPed) then @@ -688,7 +781,7 @@ local function hasEnteredMarker(zone) local vehicleData, model, resellPrice, plate if GetPedInVehicleSeat(vehicle, -1) == playerPed then - for i=1, #Vehicles, 1 do + for i = 1, #Vehicles, 1 do if joaat(Vehicles[i].model) == GetEntityModel(vehicle) then vehicleData = Vehicles[i] break @@ -700,25 +793,30 @@ local function hasEnteredMarker(zone) model = GetEntityModel(vehicle) plate = ESX.Math.Trim(GetVehicleNumberPlateText(vehicle)) - CurrentAction = 'resell_vehicle' - CurrentActionMsg = TranslateCap('sell_menu', vehicleData.name, ESX.Math.GroupDigits(resellPrice)) + CurrentAction = "resell_vehicle" + CurrentActionMsg = TranslateCap("sell_menu", vehicleData.name, ESX.Math.GroupDigits(resellPrice)) CurrentActionData = { vehicle = vehicle, label = vehicleData.name, price = resellPrice, model = model, - plate = plate + plate = plate, } else - ESX.ShowNotification(TranslateCap('invalid_vehicle')) + ESX.ShowNotification(TranslateCap("invalid_vehicle")) end end end - - elseif zone == 'BossActions' and Config.EnablePlayerManagement and LocalPlayer.state.job ~= nil and LocalPlayer.state.job.name == 'cardealer' and LocalPlayer.state.job.grade_name == 'boss' then - CurrentAction = 'boss_actions_menu' - CurrentActionMsg = TranslateCap('shop_menu') + elseif + zone == "BossActions" + and Config.EnablePlayerManagement + and LocalPlayer.state.job ~= nil + and LocalPlayer.state.job.name == "cardealer" + and LocalPlayer.state.job.grade_name == "boss" + then + CurrentAction = "boss_actions_menu" + CurrentActionMsg = TranslateCap("shop_menu") CurrentActionData = {} end end @@ -732,8 +830,10 @@ local function hasExitedMarker(zone) CurrentAction = nil end -AddEventHandler('onResourceStop', function(resource) - if resource ~= GetCurrentResourceName() then return end +AddEventHandler("onResourceStop", function(resource) + if resource ~= GetCurrentResourceName() then + return + end if IsInShopMenu then ESX.UI.Menu.CloseAll() ESX.CloseContext() @@ -756,14 +856,37 @@ CreateThread(function() local playerCoords = GetEntityCoords(ESX.PlayerData.ped) local isInMarker, letSleep, currentZone = false, true - for k,v in pairs(Config.Zones) do + for k, v in pairs(Config.Zones) do local distance = #(playerCoords - v.Pos) if distance < Config.DrawDistance then letSleep = false if v.Type ~= -1 then - DrawMarker(v.Type, v.Pos, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, v.Size.x, v.Size.y, v.Size.z, Config.MarkerColor.r, Config.MarkerColor.g, Config.MarkerColor.b, 100, false, true, 2, false, nil, nil, false) + DrawMarker( + v.Type, + v.Pos, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + 0.0, + v.Size.x, + v.Size.y, + v.Size.z, + Config.MarkerColor.r, + Config.MarkerColor.g, + Config.MarkerColor.b, + 100, + false, + true, + 2, + false, + nil, + nil, + false + ) end if distance < v.Size.x then @@ -798,39 +921,45 @@ CreateThread(function() ESX.TextUI(CurrentActionMsg) if IsControlJustReleased(0, 38) then - if CurrentAction == 'shop_menu' then + if CurrentAction == "shop_menu" then if Config.LicenseEnable then - ESX.TriggerServerCallback('esx_license:checkLicense', function(hasDriversLicense) + ESX.TriggerServerCallback("esx_license:checkLicense", function(hasDriversLicense) if hasDriversLicense then OpenShopMenu() else - ESX.ShowNotification(TranslateCap('license_missing')) + ESX.ShowNotification(TranslateCap("license_missing")) end - end, GetPlayerServerId(PlayerId()), 'drive') + end, GetPlayerServerId(PlayerId()), "drive") else OpenShopMenu() end - elseif CurrentAction == 'reseller_menu' then + elseif CurrentAction == "reseller_menu" then OpenResellerMenu() - elseif CurrentAction == 'give_back_vehicle' then - ESX.TriggerServerCallback('esx_vehicleshop:giveBackVehicle', function(isRentedVehicle) + elseif CurrentAction == "give_back_vehicle" then + ESX.TriggerServerCallback("esx_vehicleshop:giveBackVehicle", function(isRentedVehicle) if isRentedVehicle then ESX.Game.DeleteVehicle(CurrentActionData.vehicle) - ESX.ShowNotification(TranslateCap('delivered')) + ESX.ShowNotification(TranslateCap("delivered")) else - ESX.ShowNotification(TranslateCap('not_rental')) + ESX.ShowNotification(TranslateCap("not_rental")) end end, ESX.Math.Trim(GetVehicleNumberPlateText(CurrentActionData.vehicle))) - elseif CurrentAction == 'resell_vehicle' then - ESX.TriggerServerCallback('esx_vehicleshop:resellVehicle', function(vehicleSold) + elseif CurrentAction == "resell_vehicle" then + ESX.TriggerServerCallback("esx_vehicleshop:resellVehicle", function(vehicleSold) if vehicleSold then ESX.Game.DeleteVehicle(CurrentActionData.vehicle) - ESX.ShowNotification(TranslateCap('vehicle_sold_for', CurrentActionData.label, ESX.Math.GroupDigits(CurrentActionData.price))) + ESX.ShowNotification( + TranslateCap( + "vehicle_sold_for", + CurrentActionData.label, + ESX.Math.GroupDigits(CurrentActionData.price) + ) + ) else - ESX.ShowNotification(TranslateCap('not_yours')) + ESX.ShowNotification(TranslateCap("not_yours")) end end, CurrentActionData.plate, CurrentActionData.model) - elseif CurrentAction == 'boss_actions_menu' then + elseif CurrentAction == "boss_actions_menu" then OpenBossActionsMenu() end ESX.HideUI() @@ -842,4 +971,6 @@ CreateThread(function() end end) -if ESX.PlayerLoaded then PlayerManagement() end \ No newline at end of file +if ESX.PlayerLoaded then + PlayerManagement() +end