Skip to content

Commit

Permalink
refactor: utils to lib and ox locales
Browse files Browse the repository at this point in the history
* Update fxmanifest.lua

* Update main.lua

* Update main.lua

* Accidental enter

* Delete old locales

* Add new locales

* Accidentally missed IsWearingGloves()

* Remove references to qb-inventory events
  • Loading branch information
jonezkti authored Mar 3, 2024
1 parent e707b9e commit e5b9e2e
Show file tree
Hide file tree
Showing 11 changed files with 94 additions and 124 deletions.
20 changes: 10 additions & 10 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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)
Expand Down Expand Up @@ -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 = {
Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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)
end)
8 changes: 4 additions & 4 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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',
Expand Down
19 changes: 19 additions & 0 deletions locales/cs.json
Original file line number Diff line number Diff line change
@@ -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!"
}
}
28 changes: 0 additions & 28 deletions locales/cs.lua

This file was deleted.

19 changes: 19 additions & 0 deletions locales/en.json
Original file line number Diff line number Diff line change
@@ -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!"
}
}
24 changes: 0 additions & 24 deletions locales/en.lua

This file was deleted.

19 changes: 19 additions & 0 deletions locales/es.json
Original file line number Diff line number Diff line change
@@ -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!"
}
}
27 changes: 0 additions & 27 deletions locales/es.lua

This file was deleted.

18 changes: 18 additions & 0 deletions locales/fr.json
Original file line number Diff line number Diff line change
@@ -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 !"
}
}
23 changes: 0 additions & 23 deletions locales/fr.lua

This file was deleted.

13 changes: 5 additions & 8 deletions server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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

Expand All @@ -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

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e5b9e2e

Please sign in to comment.