diff --git a/client/main.lua b/client/main.lua index e31080f..26d15b8 100644 --- a/client/main.lua +++ b/client/main.lua @@ -56,7 +56,7 @@ local function alertPolice() local hours = GetClockHours() local chance = config.policeAlertChance - if IsWearingGloves() or hours >= 1 and hours <= 6 then + if qbx.isWearingGloves() or hours >= 1 and hours <= 6 then chance = config.policeNightAlertChance end @@ -66,7 +66,7 @@ local function alertPolice() end local function dropFingerprint() - if IsWearingGloves() then return end + if qbx.isWearingGloves() then return end if config.fingerprintChance > math.random(0, 100) then local coords = GetEntityCoords(cache.ped) TriggerServerEvent('evidence:server:CreateFingerDrop', coords) @@ -118,7 +118,7 @@ RegisterNUICallback('success', function(_, cb) alertPolice() if lib.progressBar({ duration = config.openRegisterTime, - label = Lang:t('text.emptying_the_register'), + label = locale('text.emptying_the_register'), useWhileDead = false, canCancel = true, disable = { @@ -133,7 +133,7 @@ RegisterNUICallback('success', function(_, cb) else -- if canceled openingRegister = false TriggerServerEvent('qbx_storerobbery:server:registerCanceled') - exports.qbx_core:Notify(Lang:t('error.process_canceled'), 'error') + exports.qbx_core:Notify(locale('error.process_canceled'), 'error') end cb('ok') end) @@ -227,11 +227,11 @@ CreateThread(function() if config.useDrawText then if not hasShownText then hasShownText = true - lib.showTextUI(Lang:t('text.register_empty'), {position = 'left-center'}) + lib.showTextUI(locale('text.register_empty'), {position = 'left-center'}) exports['qbx-core']:DrawText() end else - DrawText3D(Lang:t('text.register_empty'), sharedConfig.registers[i].coords) + qbx.drawText3d({text = locale('text.register_empty'), coords = sharedConfig.registers[i].coords}) end end end @@ -255,9 +255,9 @@ CreateThread(function() time = 0 nearby = true if sharedConfig.safes[i].robbed then - text = Lang:t('text.safe_opened') + text = locale('text.safe_opened') else - text = Lang:t('text.try_combination') + text = locale('text.try_combination') if IsControlJustPressed(0, 38) then TriggerServerEvent('qbx_storerobbery:server:trySafe') end @@ -268,11 +268,11 @@ CreateThread(function() lib.showTextUI(text, {position = 'left-center'}) end else - DrawText3D(text, sharedConfig.safes[i].coords) + qbx.drawText3d({text = text, coords = sharedConfig.safes[i].coords}) end end end if not nearby and hasShownText then hasShownText = false lib.hideTextUI() end Wait(time) end -end) \ No newline at end of file +end) diff --git a/fxmanifest.lua b/fxmanifest.lua index 32cd606..4fcf3ac 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -5,12 +5,11 @@ description 'qbx_storerobbery' repository 'https://github.com/Qbox-project/qbx_storerobbery' version '1.0.0' +ox_lib 'locale' + shared_scripts { '@ox_lib/init.lua', - '@qbx_core/modules/utils.lua', - '@qbx_core/shared/locale.lua', - 'locales/en.lua', - 'locales/*.lua', + '@qbx_core/modules/lib.lua', } client_script 'client/main.lua' @@ -19,6 +18,7 @@ server_script 'server/main.lua' ui_page 'html/index.html' files { + 'locales/*.json', 'config/client.lua', 'config/shared.lua', 'html/index.html', diff --git a/locales/cs.json b/locales/cs.json new file mode 100644 index 0000000..9dc0d2c --- /dev/null +++ b/locales/cs.json @@ -0,0 +1,19 @@ +{ + "error": { + "no_police": "Nedostatek policistů (%{Required} požadováno)", + "process_canceled": "Proces zrušen..", + "lockpick_broken": "Zlomil(a) jste lomítko" + }, + "text": { + "register_empty": "Pokladna je prázdná", + "try_combination": "~g~E~w~ - Vyzkoušet kombinaci", + "safe_opened": "Trezor otevřen", + "emptying_the_register": "Vyprazdňování pokladny..", + "safe_code": "Kód trezoru: ", + "value": "Hodnota: $%{value}" + }, + "alert": { + "register": "Někdo páčí pokladnu!", + "safe": "Někdo lámá trezor!" + } +} \ No newline at end of file diff --git a/locales/cs.lua b/locales/cs.lua deleted file mode 100644 index f00f9bf..0000000 --- a/locales/cs.lua +++ /dev/null @@ -1,28 +0,0 @@ -local Translations = { - error = { - no_police = "Nedostatek policistů (%{Required} požadováno)", - process_canceled = "Proces zrušen..", - lockpick_broken = "Zlomil(a) jste lomítko" - }, - text = { - register_empty = "Pokladna je prázdná", - try_combination = "~g~E~w~ - Vyzkoušet kombinaci", - safe_opened = "Trezor otevřen", - emptying_the_register = "Vyprazdňování pokladny..", - safe_code = "Kód trezoru: ", - value = "Hodnota: $%{value}", - }, - alert = { - register = 'Někdo páčí pokladnu!', - safe = 'Někdo lámá trezor!' - } -} - -if GetConvar('qb_locale', 'en') == 'cs' then - Lang = Locale:new({ - phrases = Translations, - warnOnMissing = true, - fallbackLang = Lang, - }) -end ---translate by stepan_valic \ No newline at end of file diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..2e245ac --- /dev/null +++ b/locales/en.json @@ -0,0 +1,19 @@ +{ + "error": { + "no_police": "Not Enough Police (%{Required} Required)", + "process_canceled": "Process canceled..", + "lockpick_broken": "You Broke The Lock Pick" + }, + "text": { + "register_empty": "The Cash Register Is Empty", + "try_combination": "~g~E~w~ - Try Combination", + "safe_opened": "Safe Opened", + "emptying_the_register": "Emptying The Register..", + "safe_code": "Safe Code: ", + "value": "Value: $%{value}" + }, + "alert": { + "register": "Someone is prying the register!", + "safe": "Someone is cracking the safe!" + } +} \ No newline at end of file diff --git a/locales/en.lua b/locales/en.lua deleted file mode 100644 index 5321a0c..0000000 --- a/locales/en.lua +++ /dev/null @@ -1,24 +0,0 @@ -local Translations = { - error = { - no_police = "Not Enough Police (%{Required} Required)", - process_canceled = "Process canceled..", - lockpick_broken = "You Broke The Lock Pick" - }, - text = { - register_empty = "The Cash Register Is Empty", - try_combination = "~g~E~w~ - Try Combination", - safe_opened = "Safe Opened", - emptying_the_register = "Emptying The Register..", - safe_code = "Safe Code: ", - value = "Value: $%{value}", - }, - alert = { - register = 'Someone is prying the register!', - safe = 'Someone is cracking the safe!' - } -} - -Lang = Lang or Locale:new({ - phrases = Translations, - warnOnMissing = true -}) diff --git a/locales/es.json b/locales/es.json new file mode 100644 index 0000000..f53b634 --- /dev/null +++ b/locales/es.json @@ -0,0 +1,19 @@ +{ + "error": { + "no_police": "No hay suficientes policia (%{Required} son requeridos)", + "process_canceled": "Proceso cancelado..", + "lockpick_broken": "Has roto la ganzúa" + }, + "text": { + "register_empty": "La caja registradora está vacía", + "try_combination": "~g~E~w~ - Ingresa la combinación", + "safe_opened": "Caja abierta", + "emptying_the_register": "Vaciando caja registradora..", + "safe_code": "Código de seguridad: ", + "value": "Valor: $%{value}" + }, + "alert": { + "register": "¡Alguien está en una registradora!", + "safe": "¡Alguien está rompiendo una caja fuerte!" + } +} \ No newline at end of file diff --git a/locales/es.lua b/locales/es.lua deleted file mode 100644 index fc6c7d4..0000000 --- a/locales/es.lua +++ /dev/null @@ -1,27 +0,0 @@ -local Translations = { - error = { - no_police = "No hay suficientes policia (%{Required} son requeridos)", - process_canceled = "Proceso cancelado..", - lockpick_broken = "Has roto la ganzúa" - }, - text = { - register_empty = "La caja registradora está vacía", - try_combination = "~g~E~w~ - Ingresa la combinación", - safe_opened = "Caja abierta", - emptying_the_register= "Vaciando caja registradora..", - safe_code = "Código de seguridad: ", - value = "Valor: $%{value}" - }, - alert = { - register = '¡Alguien está en una registradora!', - safe = '¡Alguien está rompiendo una caja fuerte!' - } -} - -if GetConvar('qb_locale', 'en') == 'es' then - Lang = Locale:new({ - phrases = Translations, - warnOnMissing = true, - fallbackLang = Lang, - }) -end diff --git a/locales/fr.json b/locales/fr.json new file mode 100644 index 0000000..ba8f450 --- /dev/null +++ b/locales/fr.json @@ -0,0 +1,18 @@ +{ + "error": { + "no_police": "Pas assez de policiers (%{Required} Requis)", + "process_canceled": "Annulé..", + "lockpick_broken": "Vous avez cassé l'outil de crochetage" + }, + "text": { + "register_empty": "La caisse est vide", + "try_combination": "~g~E~w~ - Essayer la combinaison", + "safe_opened": "Coffre-fort ouvert", + "emptying_the_register": "Vide la caisse..", + "safe_code": "Code du Coffre-fort: " + }, + "alert": { + "register": "Quelqu'un force la caisse!", + "safe": "Quelqu'un essaie de forcer le coffre-fort !" + } +} \ No newline at end of file diff --git a/locales/fr.lua b/locales/fr.lua deleted file mode 100644 index b5b43cf..0000000 --- a/locales/fr.lua +++ /dev/null @@ -1,23 +0,0 @@ -local Translations = { - error = { - no_police = "Pas assez de policiers (%{Required} Requis)", - process_canceled = "Annulé..", - lockpick_broken = "Vous avez cassé l'outil de crochetage" - }, - text = { - register_empty = "La caisse est vide", - try_combination = "~g~E~w~ - Essayer la combinaison", - safe_opened = "Coffre-fort ouvert", - emptying_the_register= "Vide la caisse..", - safe_code = "Code du Coffre-fort: " - }, -} - -if GetConvar('qb_locale', 'en') == 'fr' then - Lang = Locale:new({ - phrases = Translations, - warnOnMissing = true, - fallbackLang = Lang, - }) -end - diff --git a/server/main.lua b/server/main.lua index a01cbfd..864f6a9 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,7 +3,6 @@ local sharedConfig = require 'config.shared' local startedRegister = {} local startedSafe = {} local safeCodes = {} -local ITEMS = exports.ox_inventory:Items() local function getClosestRegister(coords) local closestRegisterIndex @@ -59,7 +58,7 @@ RegisterNetEvent('qbx_storerobbery:server:registerFailed', function(isUsingAdvan startedRegister[source] = false sharedConfig.registers[closestRegisterIndex].robbed = false if removalChance > math.random(0, 100) then - exports.qbx_core:Notify(source, Lang:t('error.lockpick_broken'), 'error') + exports.qbx_core:Notify(source, locale('error.lockpick_broken'), 'error') if isUsingAdvanced then exports.ox_inventory:RemoveItem(source, 'advancedlockpick', 1) else @@ -98,11 +97,11 @@ RegisterNetEvent('qbx_storerobbery:server:registerOpened', function(isDone) local info if sharedConfig.safes[sharedConfig.registers[closestRegisterIndex].safeKey].type == 'keypad' then info = { - label = Lang:t('text.safe_code') .. tostring(code) + label = locale('text.safe_code') .. tostring(code) } else info = { - label = Lang:t('text.safe_code') .. tostring(math.floor((code[1] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[2] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[3] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[4] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[5] % 360) / 3.60)) + label = locale('text.safe_code') .. tostring(math.floor((code[1] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[2] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[3] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[4] % 360) / 3.60)) .. "-" .. tostring(math.floor((code[5] % 360) / 3.60)) } end @@ -124,7 +123,7 @@ RegisterNetEvent('qbx_storerobbery:server:trySafe', function() if not closestSafeIndex then return end if leoCount < sharedConfig.minimumCops and sharedConfig.notEnoughCopsNotify then - exports.qbx_core:Notify(source, Lang:t('error.no_police', {Required = config.minimumCops}), 'error') + exports.qbx_core:Notify(source, locale('error.no_police', {Required = config.minimumCops}), 'error') return end @@ -152,17 +151,15 @@ RegisterNetEvent('qbx_storerobbery:server:safeCracked', function() local billsMeta = { worth = worthMarkedBills, - description = Lang:t('text.value', { value = worthMarkedBills }) + description = locale('text.value', { value = worthMarkedBills }) } player.Functions.AddItem('markedbills', numMarkedBills, false, billsMeta) if config.safeReward.chanceAtSpecial > math.random(0, 100) then player.Functions.AddItem('rolex', math.random(config.safeReward.rolexAmount.min, config.safeReward.rolexAmount.max)) - TriggerClientEvent('inventory:client:ItemBox', source, ITEMS['rolex'], 'add') if config.safeReward.chanceAtSpecial / 2 > math.random(0, 100) then player.Functions.AddItem('goldbar', config.safeReward.goldbarAmount) - TriggerClientEvent('inventory:client:ItemBox', source, ITEMS['goldbar'], 'add') end end startedSafe[source] = false