From bd5535fddfb6543c1ac7aa35c171d39daf30b5d8 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Mon, 8 Apr 2024 10:03:32 +0200 Subject: [PATCH] fix: (esx_boat) undefined variable - fix: accessing undefined variable LastZoneNum - chore: replace _U with TranslateCap --- .../[esx_addons]/esx_boat/client/main.lua | 42 +++++++++---------- .../[esx_addons]/esx_boat/client/marker.lua | 13 +++--- 2 files changed, 27 insertions(+), 28 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_boat/client/main.lua b/server-data/resources/[esx_addons]/esx_boat/client/main.lua index 4e8b67a13..d1a1cb7e2 100644 --- a/server-data/resources/[esx_addons]/esx_boat/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_boat/client/main.lua @@ -6,7 +6,7 @@ function OpenBoatShop(shop) local playerPed = PlayerPedId() local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("boat_shop") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("boat_shop") }, } for _, v in ipairs(Config.Vehicles) do @@ -55,7 +55,7 @@ function OpenBoatShop(shop) ESX.TriggerServerCallback("esx_boat:buyBoat", function(bought) if bought then ESX.ShowNotification( - _U("boat_shop_bought", element.name, ESX.Math.GroupDigits(element.price)) + TranslateCap("boat_shop_bought", element.name, ESX.Math.GroupDigits(element.price)) ) DeleteSpawnedVehicles() @@ -63,13 +63,13 @@ function OpenBoatShop(shop) ESX.CloseContext() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") FreezeEntityPosition(playerPed, false) SetEntityVisible(playerPed, true) SetEntityCoords(playerPed, shop.Outside.x, shop.Outside.y, shop.Outside.z) else - ESX.ShowNotification(_U("boat_shop_nomoney")) + ESX.ShowNotification(TranslateCap("boat_shop_nomoney")) end end, props) elseif element3.value == "stop" then @@ -83,23 +83,23 @@ function OpenBoatShop(shop) end, function() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end, function() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end function OpenBoatGarage(garage) ESX.TriggerServerCallback("esx_boat:getGarage", function(ownedBoats) if #ownedBoats == 0 then - ESX.ShowNotification(_U("garage_noboats")) + ESX.ShowNotification(TranslateCap("garage_noboats")) else -- get all available boats local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("garage") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("garage") }, } for i = 1, #ownedBoats, 1 do ownedBoats[i] = json.decode(ownedBoats[i]) @@ -117,7 +117,7 @@ function OpenBoatGarage(garage) if ESX.Game.IsSpawnPointClear(garage.SpawnPoint, 4.0) then TriggerServerEvent("esx_boat:takeOutVehicle", vehicleProps.plate) - ESX.ShowNotification(_U("garage_taken")) + ESX.ShowNotification(TranslateCap("garage_taken")) ESX.Game.SpawnVehicle(vehicleProps.model, garage.SpawnPoint, garage.SpawnPoint.w, function(vehicle) TaskWarpPedIntoVehicle(playerPed, vehicle, -1) @@ -126,11 +126,11 @@ function OpenBoatGarage(garage) ESX.CloseContext() else - ESX.ShowNotification(_U("garage_blocked")) + ESX.ShowNotification(TranslateCap("garage_blocked")) end end, function() CurrentAction = "garage_out" - CurrentActionMsg = _U("garage_open") + CurrentActionMsg = TranslateCap("garage_open") end) end end) @@ -138,15 +138,15 @@ end function OpenLicenceMenu(shop) local elements = { - { unselectable = true, icon = "fas fa-ship", title = _U("license_menu") }, + { unselectable = true, icon = "fas fa-ship", title = TranslateCap("license_menu") }, { icon = "fas fa-ship", title = "Purchase Boat License" }, } ESX.OpenContext("right", elements, function(_, element) local elements2 = { { unselectable = true, icon = "fas fa-ship", title = element.title }, - { icon = "fas fa-check-double", title = _U("license_buy_yes", Config.LicensePrice), val = "yes" }, - { icon = "fas fa-window-close", title = _U("license_buy_no"), val = "no" }, + { icon = "fas fa-check-double", title = TranslateCap("license_buy_yes", Config.LicensePrice), val = "yes" }, + { icon = "fas fa-window-close", title = TranslateCap("license_buy_no"), val = "no" }, } ESX.OpenContext("right", elements2, function(_, element2) @@ -158,21 +158,21 @@ function OpenLicenceMenu(shop) ESX.TriggerServerCallback("esx_boat:buyBoatLicense", function(boughtLicense) if boughtLicense then - ESX.ShowNotification(_U("license_bought", ESX.Math.GroupDigits(Config.LicensePrice))) + ESX.ShowNotification(TranslateCap("license_bought", ESX.Math.GroupDigits(Config.LicensePrice))) ESX.CloseContext() OpenBoatShop(shop) -- parse current shop else - ESX.ShowNotification(_U("license_nomoney")) + ESX.ShowNotification(TranslateCap("license_nomoney")) end end) end, function() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end, function() CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") end) end @@ -182,14 +182,14 @@ function StoreBoatInGarage(vehicle, teleportCoords) ESX.TriggerServerCallback("esx_boat:storeVehicle", function(rowsChanged) if rowsChanged > 0 then ESX.Game.DeleteVehicle(vehicle) - ESX.ShowNotification(_U("garage_stored")) + ESX.ShowNotification(TranslateCap("garage_stored")) local playerPed = PlayerPedId() ESX.Game.Teleport(playerPed, teleportCoords, function() SetEntityHeading(playerPed, teleportCoords.w) end) else - ESX.ShowNotification(_U("garage_notowner")) + ESX.ShowNotification(TranslateCap("garage_notowner")) end end, vehicleProps.plate) end @@ -234,7 +234,7 @@ function reset(shop) local playerPed = PlayerPedId() isInShopMenu = false CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") DeleteSpawnedVehicles() FreezeEntityPosition(playerPed, false) SetEntityVisible(playerPed, true) diff --git a/server-data/resources/[esx_addons]/esx_boat/client/marker.lua b/server-data/resources/[esx_addons]/esx_boat/client/marker.lua index 6874b750f..b8ccee1dd 100644 --- a/server-data/resources/[esx_addons]/esx_boat/client/marker.lua +++ b/server-data/resources/[esx_addons]/esx_boat/client/marker.lua @@ -1,5 +1,4 @@ -local HasAlreadyEnteredMarker = false -local LastZone = nil +local HasAlreadyEnteredMarker, LastZone, LastZoneNum = false, nil, {} CurrentAction = nil CurrentActionMsg = "" @@ -45,11 +44,11 @@ end) AddEventHandler("esx_boat:hasEnteredMarker", function(zone, zoneNum) if zone == "boat_shop" then CurrentAction = "boat_shop" - CurrentActionMsg = _U("boat_shop_open") + CurrentActionMsg = TranslateCap("boat_shop_open") CurrentActionData = { zoneNum = zoneNum } elseif zone == "garage_out" then CurrentAction = "garage_out" - CurrentActionMsg = _U("garage_open") + CurrentActionMsg = TranslateCap("garage_open") CurrentActionData = { zoneNum = zoneNum } elseif zone == "garage_in" then local playerPed = PlayerPedId() @@ -60,7 +59,7 @@ AddEventHandler("esx_boat:hasEnteredMarker", function(zone, zoneNum) if DoesEntityExist(vehicle) and GetPedInVehicleSeat(vehicle, -1) == playerPed then CurrentAction = "garage_in" - CurrentActionMsg = _U("garage_store") + CurrentActionMsg = TranslateCap("garage_store") CurrentActionData = { vehicle = vehicle, zoneNum = zoneNum } end end @@ -235,7 +234,7 @@ CreateThread(function() for i = 1, #Config.Zones.Garages, 1 do table.insert(blipList, { coords = Config.Zones.Garages[i].GaragePos, - text = _U("blip_garage"), + text = TranslateCap("blip_garage"), sprite = 356, color = 3, scale = 1.0, @@ -245,7 +244,7 @@ CreateThread(function() for i = 1, #Config.Zones.BoatShops, 1 do table.insert(blipList, { coords = Config.Zones.BoatShops[i].Outside, - text = _U("blip_shop"), + text = TranslateCap("blip_shop"), sprite = 427, color = 3, scale = 1.0,