Skip to content

Commit

Permalink
refactor(locales): qb to ox
Browse files Browse the repository at this point in the history
* refactor(locales): qb to ox

* fix: variable replacement

* fix: more locale issues

* refactor: remove ItemBox

* fix: locale for stash/armory
  • Loading branch information
solareon authored Jan 27, 2024
1 parent 93ba90c commit dc5969f
Show file tree
Hide file tree
Showing 38 changed files with 1,300 additions and 1,408 deletions.
22 changes: 11 additions & 11 deletions client/hospital.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ local function putPlayerInBed(hospitalName, bedIndex, isRevive, skipOpenCheck)
if IsInHospitalBed then return end
if not skipOpenCheck then
if lib.callback.await('qbx_ambulancejob:server:isBedTaken', false, hospitalName, bedIndex) then
exports.qbx_core:Notify(Lang:t('error.beds_taken'), 'error')
exports.qbx_core:Notify(locale('error.beds_taken'), 'error')
return
end
end
Expand All @@ -66,7 +66,7 @@ local function putPlayerInBed(hospitalName, bedIndex, isRevive, skipOpenCheck)
CreateThread(function()
Wait(5)
if isRevive then
exports.qbx_core:Notify(Lang:t('success.being_helped'), 'success')
exports.qbx_core:Notify(locale('success.being_helped'), 'success')
Wait(config.aiHealTimer * 1000)
TriggerEvent('hospital:client:Revive')
else
Expand All @@ -89,7 +89,7 @@ local function checkIn(hospitalName)
if lib.progressCircle({
duration = 2000,
position = 'bottom',
label = Lang:t('progress.checking_in'),
label = locale('progress.checking_in'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -104,7 +104,7 @@ local function checkIn(hospitalName)
lib.callback('qbx_ambulancejob:server:checkIn', false, nil, cache.serverId, hospitalName)
else
exports.scully_emotemenu:cancelEmote()
exports.qbx_core:Notify(Lang:t('error.canceled'), 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end

Expand All @@ -129,7 +129,7 @@ if config.useTarget then
checkIn(hospitalName)
end,
icon = 'fas fa-clipboard',
label = Lang:t('text.check'),
label = locale('text.check'),
distance = 1.5,
}
}
Expand All @@ -150,7 +150,7 @@ if config.useTarget then
putPlayerInBed(hospitalName, i, false)
end,
icon = 'fas fa-clipboard',
label = Lang:t('text.bed'),
label = locale('text.bed'),
distance = 1.5,
},
{
Expand All @@ -165,7 +165,7 @@ if config.useTarget then
end
end,
icon = 'fas fa-clipboard',
label = Lang:t('text.put_bed'),
label = locale('text.put_bed'),
distance = 1.5,
}
}
Expand All @@ -181,9 +181,9 @@ else
local function enterCheckInZone()
local numDoctors = lib.callback.await('qbx_ambulancejob:server:getNumDoctors')
if numDoctors >= sharedConfig.minForCheckIn then
lib.showTextUI(Lang:t('text.call_doc'))
lib.showTextUI(locale('text.call_doc'))
else
lib.showTextUI(Lang:t('text.check_in'))
lib.showTextUI(locale('text.check_in'))
end
end

Expand Down Expand Up @@ -213,7 +213,7 @@ else
local bed = hospital.beds[i]
local function enterBedZone()
if not IsInHospitalBed then
lib.showTextUI(Lang:t('text.lie_bed'))
lib.showTextUI(locale('text.lie_bed'))
end
end

Expand Down Expand Up @@ -271,7 +271,7 @@ end
CreateThread(function()
while true do
if IsInHospitalBed and CanLeaveBed then
lib.showTextUI(Lang:t('text.bed_out'))
lib.showTextUI(locale('text.bed_out'))
while IsInHospitalBed and CanLeaveBed do
OnKeyPress(leaveBed)
Wait(0)
Expand Down
64 changes: 32 additions & 32 deletions client/job.lua
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ local function showGarageMenu(vehicles, vehiclePlatePrefix, coords)

lib.registerContext({
id = 'ambulance_garage_context_menu',
title = Lang:t('menu.amb_vehicles'),
title = locale('menu.amb_vehicles'),
options = optionsMenu
})
lib.showContext('ambulance_garage_context_menu')
Expand All @@ -69,7 +69,7 @@ local function showTreatmentMenu(status)

lib.registerContext({
id = 'ambulance_status_context_menu',
title = Lang:t('menu.status'),
title = locale('menu.status'),
options = statusMenu
})
lib.showContext('ambulance_status_context_menu')
Expand All @@ -80,31 +80,31 @@ end
RegisterNetEvent('hospital:client:CheckStatus', function()
local player = GetClosestPlayer()
if not player then
exports.qbx_core:Notify(Lang:t('error.no_player'), 'error')
exports.qbx_core:Notify(locale('error.no_player'), 'error')
return
end
local playerId = GetPlayerServerId(player)


local status = lib.callback.await('qbx_ambulancejob:server:getPlayerStatus', false, playerId)
if #status.injuries == 0 then
exports.qbx_core:Notify(Lang:t('success.healthy_player'), 'success')
exports.qbx_core:Notify(locale('success.healthy_player'), 'success')
return
end

for hash in pairs(status.damageCauses) do
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = false,
args = { Lang:t('info.status'), WEAPONS[hash].damagereason }
args = { locale('info.status'), WEAPONS[hash].damagereason }
})
end

if status.bleedLevel > 0 then
TriggerEvent('chat:addMessage', {
color = { 255, 0, 0 },
multiline = false,
args = { Lang:t('info.status'), Lang:t('info.is_status', { status = status.bleedState }) }
args = { locale('info.status'), locale('info.is_status', status.bleedState) }
})
end

Expand All @@ -116,20 +116,20 @@ end)
RegisterNetEvent('hospital:client:RevivePlayer', function()
local hasFirstAid = exports.ox_inventory:Search('count', 'firstaid') > 0
if not hasFirstAid then
exports.qbx_core:Notify(Lang:t('error.no_firstaid'), 'error')
exports.qbx_core:Notify(locale('error.no_firstaid'), 'error')
return
end

local player = GetClosestPlayer()
if not player then
exports.qbx_core:Notify(Lang:t('error.no_player'), 'error')
exports.qbx_core:Notify(locale('error.no_player'), 'error')
return
end

if lib.progressCircle({
duration = 5000,
position = 'bottom',
label = Lang:t('progress.revive'),
label = locale('progress.revive'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -145,11 +145,11 @@ RegisterNetEvent('hospital:client:RevivePlayer', function()
})
then
StopAnimTask(cache.ped, HealAnimDict, 'exit', 1.0)
exports.qbx_core:Notify(Lang:t('success.revived'), 'success')
exports.qbx_core:Notify(locale('success.revived'), 'success')
TriggerServerEvent('hospital:server:RevivePlayer', GetPlayerServerId(player))
else
StopAnimTask(cache.ped, HealAnimDict, 'exit', 1.0)
exports.qbx_core:Notify(Lang:t('error.canceled'), 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

Expand All @@ -158,20 +158,20 @@ end)
RegisterNetEvent('hospital:client:TreatWounds', function()
local hasBandage = exports.ox_inventory:Search('count', 'bandage') > 0
if not hasBandage then
exports.qbx_core:Notify(Lang:t('error.no_bandage'), 'error')
exports.qbx_core:Notify(locale('error.no_bandage'), 'error')
return
end

local player = GetClosestPlayer()
if not player then
exports.qbx_core:Notify(Lang:t('error.no_player'), 'error')
exports.qbx_core:Notify(locale('error.no_player'), 'error')
return
end

if lib.progressCircle({
duration = 5000,
position = 'bottom',
label = Lang:t('progress.healing'),
label = locale('progress.healing'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -187,11 +187,11 @@ RegisterNetEvent('hospital:client:TreatWounds', function()
})
then
StopAnimTask(cache.ped, HealAnimDict, 'exit', 1.0)
exports.qbx_core:Notify(Lang:t('success.helped_player'), 'success')
exports.qbx_core:Notify(locale('success.helped_player'), 'success')
TriggerServerEvent('hospital:server:TreatWounds', GetPlayerServerId(player))
else
StopAnimTask(cache.ped, HealAnimDict, 'exit', 1.0)
exports.qbx_core:Notify(Lang:t('error.canceled'), 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)

Expand Down Expand Up @@ -271,7 +271,7 @@ local function createGarage(vehicles, vehiclePlatePrefix, coords)

local function inVehicleZone()
if QBX.PlayerData.job.name == 'ambulance' and QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.veh_button'))
lib.showTextUI(locale('text.veh_button'))
checkGarageAction(vehicles, vehiclePlatePrefix, coords)
else
checkVehicle = false
Expand All @@ -297,11 +297,11 @@ end
---Creates air and land garages to spawn vehicles at for EMS personnel
CreateThread(function()
for _, coords in pairs(sharedConfig.locations.vehicle) do
createGarage(config.authorizedVehicles, Lang:t('info.amb_plate'), coords)
createGarage(config.authorizedVehicles, locale('info.amb_plate'), coords)
end

for _, coords in pairs(sharedConfig.locations.helicopter) do
createGarage(config.authorizedHelicopters, Lang:t('info.heli_plate'), coords)
createGarage(config.authorizedHelicopters, locale('info.heli_plate'), coords)
end
end)

Expand All @@ -320,7 +320,7 @@ if config.useTarget then
type = 'client',
onSelect = toggleDuty,
icon = 'fa fa-clipboard',
label = Lang:t('text.duty'),
label = locale('text.duty'),
distance = 2,
groups = 'ambulance',
}
Expand All @@ -339,7 +339,7 @@ if config.useTarget then
type = 'client',
onSelect = openStash,
icon = 'fa fa-clipboard',
label = Lang:t('text.pstash'),
label = locale('text.pstash'),
distance = 2,
groups = 'ambulance',
}
Expand All @@ -358,7 +358,7 @@ if config.useTarget then
type = 'client',
onSelect = openArmory,
icon = 'fa fa-clipboard',
label = Lang:t('text.armory'),
label = locale('text.armory'),
distance = 1.5,
groups = 'ambulance',
}
Expand All @@ -376,7 +376,7 @@ if config.useTarget then
type = 'client',
onSelect = teleportToMainElevator,
icon = 'fas fa-hand-point-down',
label = Lang:t('text.el_main'),
label = locale('text.el_main'),
distance = 1.5,
groups = 'ambulance',
}
Expand All @@ -393,7 +393,7 @@ if config.useTarget then
type = 'client',
onSelect = teleportToRoofElevator,
icon = 'fas fa-hand-point-up',
label = Lang:t('text.el_roof'),
label = locale('text.el_roof'),
distance = 1.5,
groups = 'ambulance',
}
Expand All @@ -405,9 +405,9 @@ else
for i = 1, #sharedConfig.locations.duty do
local function enteredSignInZone()
if not QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.onduty_button'))
lib.showTextUI(locale('text.onduty_button'))
else
lib.showTextUI(Lang:t('text.offduty_button'))
lib.showTextUI(locale('text.offduty_button'))
end
end

Expand All @@ -433,7 +433,7 @@ else
for i = 1, #sharedConfig.locations.stash do
local function enteredStashZone()
if QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.pstash_button'))
lib.showTextUI(locale('text.pstash_button'))
end
end

Expand All @@ -459,7 +459,7 @@ else
for i = 1, #sharedConfig.locations.armory do
local function enteredArmoryZone()
if QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.armory_button'))
lib.showTextUI(locale('text.armory_button'))
end
end

Expand All @@ -484,9 +484,9 @@ else

local function enteredRoofZone()
if QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.elevator_main'))
lib.showTextUI(locale('text.elevator_main'))
else
lib.showTextUI(Lang:t('error.not_ems'))
lib.showTextUI(locale('error.not_ems'))
end
end

Expand All @@ -510,9 +510,9 @@ else

local function enteredMainZone()
if QBX.PlayerData.job.onduty then
lib.showTextUI(Lang:t('text.elevator_roof'))
lib.showTextUI(locale('text.elevator_roof'))
else
lib.showTextUI(Lang:t('error.not_ems'))
lib.showTextUI(locale('error.not_ems'))
end
end

Expand Down
8 changes: 4 additions & 4 deletions client/laststand.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ end)
---Use first aid pack on nearest player.
lib.callback.register('hospital:client:UseFirstAid', function()
if isEscorting then
exports.qbx_core:Notify(Lang:t('error.impossible'), 'error')
exports.qbx_core:Notify(locale('error.impossible'), 'error')
return
end

Expand All @@ -30,7 +30,7 @@ RegisterNetEvent('hospital:client:HelpPerson', function(targetId)
if lib.progressCircle({
duration = math.random(30000, 60000),
position = 'bottom',
label = Lang:t('progress.revive'),
label = locale('progress.revive'),
useWhileDead = false,
canCancel = true,
disable = {
Expand All @@ -46,10 +46,10 @@ RegisterNetEvent('hospital:client:HelpPerson', function(targetId)
})
then
ClearPedTasks(cache.ped)
exports.qbx_core:Notify(Lang:t('success.revived'), 'success')
exports.qbx_core:Notify(locale('success.revived'), 'success')
TriggerServerEvent('hospital:server:RevivePlayer', targetId)
else
ClearPedTasks(cache.ped)
exports.qbx_core:Notify(Lang:t('error.canceled'), 'error')
exports.qbx_core:Notify(locale('error.canceled'), 'error')
end
end)
Loading

0 comments on commit dc5969f

Please sign in to comment.