From fc51eebda023d9773b8f049a216669917015ab28 Mon Sep 17 00:00:00 2001 From: bitpredator <67551273+bitpredator@users.noreply.github.com> Date: Tue, 9 Apr 2024 11:32:31 +0200 Subject: [PATCH] chore: (esx_ambulancejob) replace _U with TranslateCap + fix accessing undefined variable --- .../esx_ambulancejob/client/job.lua | 70 +++++++++---------- .../esx_ambulancejob/client/main.lua | 18 ++--- .../esx_ambulancejob/client/vehicle.lua | 42 +++++------ .../esx_ambulancejob/server/main.lua | 18 ++--- 4 files changed, 74 insertions(+), 74 deletions(-) diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua index 64d823b38..a71db3fa2 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/job.lua @@ -1,18 +1,18 @@ local CurrentAction, CurrentActionMsg, CurrentActionData = nil, "", {} local HasAlreadyEnteredMarker, LastHospital, LastPart, LastPartNum -local isBusy, deadPlayers, deadPlayerBlips, isOnDuty = false, {}, {}, false +local isBusy, deadPlayers, deadPlayerBlips, isOnDuty, vehicle = false, {}, {}, false, {} isInShopMenu = false function OpenAmbulanceActionsMenu() local elements = { { unselectable = true, icon = "fas fa-shirt", title = "Ambulance Actions" }, - { icon = "fas fa-shirt", title = _U("cloakroom"), value = "cloakroom" }, + { icon = "fas fa-shirt", title = TranslateCap("cloakroom"), value = "cloakroom" }, } if Config.EnablePlayerManagement and ESX.PlayerData.job.grade_name == "boss" then elements[#elements + 1] = { icon = "fas fa-ambulance", - title = _U("boss_actions"), + title = TranslateCap("boss_actions"), value = "boss_actions", } end @@ -30,20 +30,20 @@ end function OpenMobileAmbulanceActionsMenu() local elements = { - { unselectable = true, icon = "fas fa-ambulance", title = _U("ambulance") }, - { icon = "fas fa-ambulance", title = _U("ems_menu"), value = "citizen_interaction" }, + { unselectable = true, icon = "fas fa-ambulance", title = TranslateCap("ambulance") }, + { icon = "fas fa-ambulance", title = TranslateCap("ems_menu"), value = "citizen_interaction" }, } ESX.OpenContext("right", elements, function(_, element) if element.value == "citizen_interaction" then local elements2 = { { unselectable = true, icon = "fas fa-ambulance", title = element.title }, - { icon = "fas fa-syringe", title = _U("ems_menu_revive"), value = "revive" }, - { icon = "fas fa-bandage", title = _U("ems_menu_small"), value = "small" }, - { icon = "fas fa-bandage", title = _U("ems_menu_big"), value = "big" }, - { icon = "fas fa-car", title = _U("ems_menu_putincar"), value = "put_in_vehicle" }, - { icon = "fas fa-syringe", title = _U("ems_menu_search"), value = "search" }, - { icon = "fas fa-syringe", title = _U("billing"), value = "billing" }, + { icon = "fas fa-syringe", title = TranslateCap("ems_menu_revive"), value = "revive" }, + { icon = "fas fa-bandage", title = TranslateCap("ems_menu_small"), value = "small" }, + { icon = "fas fa-bandage", title = TranslateCap("ems_menu_big"), value = "big" }, + { icon = "fas fa-car", title = TranslateCap("ems_menu_putincar"), value = "put_in_vehicle" }, + { icon = "fas fa-syringe", title = TranslateCap("ems_menu_search"), value = "search" }, + { icon = "fas fa-syringe", title = TranslateCap("billing"), value = "billing" }, } ESX.OpenContext("right", elements2, function(_, element2) @@ -56,7 +56,7 @@ function OpenMobileAmbulanceActionsMenu() if element2.value == "search" then TriggerServerEvent("esx_ambulancejob:svsearch") elseif closestPlayer == -1 or closestDistance > 1.0 then - ESX.ShowNotification(_U("no_players")) + ESX.ShowNotification(TranslateCap("no_players")) else if element2.value == "revive" then revivePlayer(closestPlayer) @@ -70,7 +70,7 @@ function OpenMobileAmbulanceActionsMenu() local playerPed = PlayerPedId() isBusy = true - ESX.ShowNotification(_U("heal_inprogress")) + ESX.ShowNotification(TranslateCap("heal_inprogress")) TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true) Wait(10000) ClearPedTasks(playerPed) @@ -81,13 +81,13 @@ function OpenMobileAmbulanceActionsMenu() GetPlayerServerId(closestPlayer), "small" ) - ESX.ShowNotification(_U("heal_complete", GetPlayerName(closestPlayer))) + ESX.ShowNotification(TranslateCap("heal_complete", GetPlayerName(closestPlayer))) isBusy = false else - ESX.ShowNotification(_U("player_not_conscious")) + ESX.ShowNotification(TranslateCap("player_not_conscious")) end else - ESX.ShowNotification(_U("not_enough_bandage")) + ESX.ShowNotification(TranslateCap("not_enough_bandage")) end end, "bandage") elseif element2.value == "big" then @@ -100,20 +100,20 @@ function OpenMobileAmbulanceActionsMenu() local playerPed = PlayerPedId() isBusy = true - ESX.ShowNotification(_U("heal_inprogress")) + ESX.ShowNotification(TranslateCap("heal_inprogress")) TaskStartScenarioInPlace(playerPed, "CODE_HUMAN_MEDIC_TEND_TO_DEAD", 0, true) Wait(10000) ClearPedTasks(playerPed) TriggerServerEvent("esx_ambulancejob:removeItem", "medikit") TriggerServerEvent("esx_ambulancejob:heal", GetPlayerServerId(closestPlayer), "big") - ESX.ShowNotification(_U("heal_complete", GetPlayerName(closestPlayer))) + ESX.ShowNotification(TranslateCap("heal_complete", GetPlayerName(closestPlayer))) isBusy = false else - ESX.ShowNotification(_U("player_not_conscious")) + ESX.ShowNotification(TranslateCap("player_not_conscious")) end else - ESX.ShowNotification(_U("not_enough_medikit")) + ESX.ShowNotification(TranslateCap("not_enough_medikit")) end end, "medikit") elseif element2.value == "put_in_vehicle" then @@ -130,16 +130,16 @@ local billing if billing == "billing" then ESX.UI.Menu.Open("dialog", GetCurrentResourceName(), "billing", { - title = _U("invoice_amount"), + title = TranslateCap("invoice_amount"), }, function(data, menu) local amount = tonumber(data.value) if amount == nil then - ESX.ShowNotification(_U("amount_invalid")) + ESX.ShowNotification(TranslateCap("amount_invalid")) else menu.close() local closestPlayer, closestDistance = ESX.Game.GetClosestPlayer() if closestPlayer == -1 or closestDistance > 3.0 then - ESX.ShowNotification(_U("no_players_near")) + ESX.ShowNotification(TranslateCap("no_players_near")) else TriggerServerEvent( "esx_billing:sendBill", @@ -148,7 +148,7 @@ if billing == "billing" then "Ambulance", amount ) - ESX.ShowNotification(_U("billing_sent")) + ESX.ShowNotification(TranslateCap("billing_sent")) end end end, function(_, menu) @@ -167,7 +167,7 @@ function revivePlayer(closestPlayer) if IsPedDeadOrDying(closestPlayerPed, 1) then local playerPed = PlayerPedId() local lib, anim = "mini@cpr@char_a@cpr_str", "cpr_pumpchest" - ESX.ShowNotification(_U("revive_inprogress")) + ESX.ShowNotification(TranslateCap("revive_inprogress")) for _ = 1, 15 do Wait(900) @@ -180,10 +180,10 @@ function revivePlayer(closestPlayer) TriggerServerEvent("esx_ambulancejob:removeItem", "medikit") TriggerServerEvent("esx_ambulancejob:revive", GetPlayerServerId(closestPlayer)) else - ESX.ShowNotification(_U("player_not_unconscious")) + ESX.ShowNotification(TranslateCap("player_notTranslateCapnconscious")) end else - ESX.ShowNotification(_U("not_enough_medikit")) + ESX.ShowNotification(TranslateCap("not_enough_medikit")) end isBusy = false end, "medikit") @@ -422,15 +422,15 @@ end) AddEventHandler("esx_ambulancejob:hasEnteredMarker", function(hospital, part, partNum) if part == "AmbulanceActions" then CurrentAction = part - CurrentActionMsg = _U("actions_prompt") + CurrentActionMsg = TranslateCap("actions_prompt") CurrentActionData = {} elseif part == "Vehicles" then CurrentAction = part - CurrentActionMsg = _U("garage_prompt") + CurrentActionMsg = TranslateCap("garage_prompt") CurrentActionData = { hospital = hospital, partNum = partNum } elseif part == "Helicopters" then CurrentAction = part - CurrentActionMsg = _U("helicopter_prompt") + CurrentActionMsg = TranslateCap("helicopter_prompt") CurrentActionData = { hospital = hospital, partNum = partNum } end end) @@ -504,9 +504,9 @@ end) function OpenCloakroomMenu() local elements = { - { unselectable = true, icon = "fas fa-shirt", title = _U("cloakroom") }, - { icon = "fas fa-shirt", title = _U("ems_clothes_civil"), value = "citizen_wear" }, - { icon = "fas fa-shirt", title = _U("ems_clothes_ems"), value = "ambulance_wear" }, + { unselectable = true, icon = "fas fa-shirt", title = TranslateCap("cloakroom") }, + { icon = "fas fa-shirt", title = TranslateCap("ems_clothes_civil"), value = "citizen_wear" }, + { icon = "fas fa-shirt", title = TranslateCap("ems_clothes_ems"), value = "ambulance_wear" }, } ESX.OpenContext("right", elements, function(_, element) @@ -549,7 +549,7 @@ AddEventHandler("esx_ambulancejob:heal", function(healType, quiet) end if not quiet then - ESX.ShowNotification(_U("healed")) + ESX.ShowNotification(TranslateCap("healed")) end end) @@ -587,7 +587,7 @@ AddEventHandler("esx_ambulancejob:setDeadPlayers", function(_deadPlayers) SetBlipCategory(blip, 7) BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(_U("blip_dead")) + AddTextComponentSubstringPlayerName(TranslateCap("blip_dead")) EndTextCommandSetBlipName(blip) deadPlayerBlips[playerId] = blip diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua index 51844b155..10ef47fb3 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/main.lua @@ -60,7 +60,7 @@ CreateThread(function() SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") - AddTextComponentSubstringPlayerName(_U("blip_hospital")) + AddTextComponentSubstringPlayerName(TranslateCap("blip_hospital")) EndTextCommandSetBlipName(blip) end end) @@ -161,7 +161,7 @@ AddEventHandler("esx_ambulancejob:useItem", function(itemName) end TriggerEvent("esx_ambulancejob:heal", "big", true) - ESX.ShowNotification(_U("used_medikit")) + ESX.ShowNotification(TranslateCap("used_medikit")) end) elseif itemName == "bandage" then local lib, anim = "anim@heists@narcotics@funding@gang_idle", "gang_chatting_idle01" -- TODO better animations @@ -177,7 +177,7 @@ AddEventHandler("esx_ambulancejob:useItem", function(itemName) end TriggerEvent("esx_ambulancejob:heal", "small", true) - ESX.ShowNotification(_U("used_bandage")) + ESX.ShowNotification(TranslateCap("used_bandage")) end) end end) @@ -197,7 +197,7 @@ function StartDistressSignal() SetTextDropShadow() SetTextOutline() BeginTextCommandDisplayText("STRING") - AddTextComponentSubstringPlayerName(_U("distress_send")) + AddTextComponentSubstringPlayerName(TranslateCap("distress_send")) EndTextCommandDisplayText(0.175, 0.805) if IsControlJustReleased(0, 47) then @@ -212,7 +212,7 @@ function SendDistressSignal() local playerPed = PlayerPedId() local coords = GetEntityCoords(playerPed) - ESX.ShowNotification(_U("distress_sent")) + ESX.ShowNotification(TranslateCap("distress_sent")) TriggerServerEvent("esx_ambulancejob:onPlayerDistress") end @@ -278,7 +278,7 @@ function StartDeathTimer() -- early respawn timer while earlySpawnTimer > 0 and isDead do Wait(0) - text = _U("respawn_available_in", secondsToClock(earlySpawnTimer)) + text = TranslateCap("respawn_available_in", secondsToClock(earlySpawnTimer)) DrawGenericTextThisFrame() @@ -290,17 +290,17 @@ function StartDeathTimer() -- bleedout timer while bleedoutTimer > 0 and isDead do Wait(0) - text = _U("respawn_bleedout_in", secondsToClock(bleedoutTimer)) + text = TranslateCap("respawn_bleedout_in", secondsToClock(bleedoutTimer)) if not Config.EarlyRespawnFine then - text = text .. _U("respawn_bleedout_prompt") + text = text .. TranslateCap("respawn_bleedout_prompt") if IsControlPressed(0, 38) and timeHeld > 60 then RemoveItemsAfterRPDeath() break end elseif Config.EarlyRespawnFine and canPayFine then - text = text .. _U("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) + text = text .. TranslateCap("respawn_bleedout_fine", ESX.Math.GroupDigits(Config.EarlyRespawnFineAmount)) if IsControlPressed(0, 38) and timeHeld > 60 then TriggerServerEvent("esx_ambulancejob:payFine") diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua index f87f6421c..30bb24b4b 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/client/vehicle.lua @@ -3,10 +3,10 @@ local spawnedVehicles = {} function OpenVehicleSpawnerMenu(type, hospital, part, partNum) local playerCoords = GetEntityCoords(PlayerPedId()) local elements = { - { unselectable = true, icon = "fas fa-car", title = _U("garage_title") }, - { icon = "fas fa-car", title = _U("garage_storeditem"), action = "garage" }, - { icon = "fas fa-car", title = _U("garage_storeitem"), action = "store_garage" }, - { icon = "fas fa-car", title = _U("garage_buyitem"), action = "buy_vehicle" }, + { unselectable = true, icon = "fas fa-car", title = TranslateCap("garage_title") }, + { icon = "fas fa-car", title = TranslateCap("garage_storeditem"), action = "garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_storeitem"), action = "store_garage" }, + { icon = "fas fa-car", title = TranslateCap("garage_buyitem"), action = "buy_vehicle" }, } ESX.OpenContext("right", elements, function(_, element) if element.action == "buy_vehicle" then @@ -23,7 +23,7 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) icon = "fas fa-car", title = ('%s - %s'):format( vehicleLabel, - _U("shop_item", ESX.Math.GroupDigits(vehicle.price)) + TranslateCap("shop_item", ESX.Math.GroupDigits(vehicle.price)) ), name = vehicleLabel, model = vehicle.model, @@ -37,10 +37,10 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) if #shopElements > 0 then OpenShopMenu(shopElements, playerCoords, shopCoords) else - ESX.ShowNotification(_U("garage_notauthorized")) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end else - ESX.ShowNotification(_U("garage_notauthorized")) + ESX.ShowNotification(TranslateCap("garage_notauthorized")) end elseif element.action == "garage" then local garage = { @@ -62,10 +62,10 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) ) if v.stored then - label = label .. ('%s'):format(_U("garage_stored")) + label = label .. ('%s'):format(TranslateCap("garage_stored")) else label = label - .. ('%s'):format(_U("garage_notstored")) + .. ('%s'):format(TranslateCap("garage_notstored")) end garage[#garage + 1] = { @@ -100,19 +100,19 @@ function OpenVehicleSpawnerMenu(type, hospital, part, partNum) elementG.plate, false ) - ESX.ShowNotification(_U("garage_released")) + ESX.ShowNotification(TranslateCap("garage_released")) end ) end else - ESX.ShowNotification(_U("garage_notavailable")) + ESX.ShowNotification(TranslateCap("garage_notavailable")) end end) else - ESX.ShowNotification(_U("garage_empty")) + ESX.ShowNotification(TranslateCap("garage_empty")) end else - ESX.ShowNotification(_U("garage_empty")) + ESX.ShowNotification(TranslateCap("garage_empty")) end end, type) elseif element.action == "store_garage" then @@ -135,7 +135,7 @@ function StoreNearbyVehicle(playerCoords) end end else - ESX.ShowNotification(_U("garage_store_nearby")) + ESX.ShowNotification(TranslateCap("garage_store_nearby")) return end @@ -149,7 +149,7 @@ function StoreNearbyVehicle(playerCoords) CreateThread(function() while isBusy do Wait(0) - drawLoadingText(_U("garage_storing"), 255, 255, 255, 255) + drawLoadingText(TranslateCap("garage_storing"), 255, 255, 255, 255) end end) @@ -175,9 +175,9 @@ function StoreNearbyVehicle(playerCoords) end isBusy = false - ESX.ShowNotification(_U("garage_has_stored")) + ESX.ShowNotification(TranslateCap("garage_has_stored")) else - ESX.ShowNotification(_U("garage_has_notstored")) + ESX.ShowNotification(TranslateCap("garage_has_notstored")) end end, vehiclePlates) end @@ -196,7 +196,7 @@ function GetAvailableVehicleSpawnPoint(hospital, part, partNum) if found then return true, foundSpawnPoint else - ESX.ShowNotification(_U("garage_blocked")) + ESX.ShowNotification(TranslateCap("garage_blocked")) return false end end @@ -251,7 +251,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.TriggerServerCallback("esx_ambulancejob:buyJobVehicle", function(bought) if bought then ESX.ShowNotification( - _U("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price)) + TranslateCap("vehicleshop_bought", element.name, ESX.Math.GroupDigits(element.price)) ) isInShopMenu = false @@ -262,7 +262,7 @@ function OpenShopMenu(elements, restoreCoords, shopCoords) ESX.Game.Teleport(playerPed, restoreCoords) else - ESX.ShowNotification(_U("vehicleshop_money")) + ESX.ShowNotification(TranslateCap("vehicleshop_money")) ESX.CloseContext() end end, props, element.type) @@ -301,7 +301,7 @@ function WaitForVehicleToLoad(modelHash) RequestModel(modelHash) BeginTextCommandBusyspinnerOn("STRING") - AddTextComponentSubstringPlayerName(_U("vehicleshop_awaiting_model")) + AddTextComponentSubstringPlayerName(TranslateCap("vehicleshop_awaiting_model")) EndTextCommandBusyspinnerOn(4) while not HasModelLoaded(modelHash) do diff --git a/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua b/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua index cb6dac6d1..5ace2dc5f 100644 --- a/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua +++ b/server-data/resources/[esx_addons]/esx_ambulancejob/server/main.lua @@ -22,18 +22,18 @@ AddEventHandler("esx_ambulancejob:revive", function(playerId) if xTarget then if deadPlayers[playerId] then if Config.ReviveReward > 0 then - xPlayer.showNotification(_U("revive_complete_award", xTarget.name, Config.ReviveReward)) + xPlayer.showNotification(TranslateCap("revive_complete_award", xTarget.name, Config.ReviveReward)) xPlayer.addMoney(Config.ReviveReward, "Revive Reward") xTarget.triggerEvent("esx_ambulancejob:revive") else - xPlayer.showNotification(_U("revive_complete", xTarget.name)) + xPlayer.showNotification(TranslateCap("revive_complete", xTarget.name)) xTarget.triggerEvent("esx_ambulancejob:revive") end else - xPlayer.showNotification(_U("player_not_unconscious")) + xPlayer.showNotification(TranslateCap("player_notTranslateCapnconscious")) end else - xPlayer.showNotification(_U("revive_fail_offline")) + xPlayer.showNotification(TranslateCap("revive_fail_offline")) end end end) @@ -148,7 +148,7 @@ if Config.EarlyRespawnFine then local xPlayer = ESX.GetPlayerFromId(source) local fineAmount = Config.EarlyRespawnFineAmount - xPlayer.showNotification(_U("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) + xPlayer.showNotification(TranslateCap("respawn_bleedout_fine_msg", ESX.Math.GroupDigits(fineAmount))) xPlayer.removeAccountMoney("bank", fineAmount, "Respawn Fine") end) end @@ -250,9 +250,9 @@ AddEventHandler("esx_ambulancejob:removeItem", function(item) xPlayer.removeInventoryItem(item, 1) if item == "bandage" then - xPlayer.showNotification(_U("used_bandage")) + xPlayer.showNotification(TranslateCap("used_bandage")) elseif item == "medikit" then - xPlayer.showNotification(_U("used_medikit")) + xPlayer.showNotification(TranslateCap("used_medikit")) end end) @@ -271,7 +271,7 @@ AddEventHandler("esx_ambulancejob:giveItem", function(itemName, amount) if xPlayer.canCarryItem(itemName, amount) then xPlayer.addInventoryItem(itemName, amount) else - xPlayer.showNotification(_U("max_item")) + xPlayer.showNotification(TranslateCap("max_item")) end end) @@ -283,7 +283,7 @@ ESX.RegisterCommand( end, true, { - help = _U("revive_help"), + help = TranslateCap("revive_help"), validate = true, arguments = { { name = "playerId", help = "The player id", type = "player" },