diff --git a/README.md b/README.md index 36e17dc..f78fe3f 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ - Customisable points for Selling materials - Nicely animated for better immersion -- Supports QBOX +- Supports QBOX and ESX - Easily adaptable to your own framework --- diff --git a/client/functions.lua b/client/functions.lua index da0bf09..2b7b355 100644 --- a/client/functions.lua +++ b/client/functions.lua @@ -1,3 +1,5 @@ +lib.locale() + function AddNetworkPropTarget(entity, options) if Config.Integrations.target == "ox_target" then exports.ox_target:addEntity(entity, options) @@ -11,14 +13,16 @@ function Notif(src, msg) if Config.Integrations.notify == "ox_lib" then TriggerEvent('ox_lib:notify', { type = 'success', - title = 'Construction Robbery', + title = locale('name_robbery'), description = msg, duration = 5000, position = 'top-right' }) - return + elseif Config.Integrations.notify == 'esx' then + exports["esx_notify"]:Notify("success", 3000, msg, locale('name_robbery')) + else + print("[ERROR] No Notify integration found.") end - print("[ERROR] No Notify integration found.") end function RandomMiniGame() local minigames = {'qte', 'circle', 'memory', 'math', 'reaction'} @@ -30,7 +34,7 @@ function ProgressBar(label, duration, options) if Config.Integrations.progressbar == "ox_lib" then return lib.progressBar({ duration = duration or 3000, - label = label or 'Working...', + label = label or locale('work'), useWhileDead = options.useWhileDead or false, canCancel = options.canCancel ~= false, disable = options.disable or { diff --git a/client/main.lua b/client/main.lua index fb3f0c6..01bef8c 100644 --- a/client/main.lua +++ b/client/main.lua @@ -321,11 +321,11 @@ Citizen.CreateThread(function() { name = 'loot_construction_safe', icon = 'fa-solid fa-box-open', - label = 'Loot '.. lootData.name, + label = locale('loot_name', lootData.name) , distance = 3.0, onSelect = function() - local success = ProgressBar('Looting '.. lootData.name ..'...', 5000, { + local success = ProgressBar(locale('loot',lootData.name), 5000, { anim = { dict = lootData.lootAnimation.dict, @@ -336,7 +336,7 @@ Citizen.CreateThread(function() local success = RunMiniGame(lootData.minigame) if not success then - Notif(PlayerId(), 'You failed to loot the '.. lootData.name ..'.') + Notif(PlayerId(), locale('fail_loot',lootData.name)) return end TriggerServerEvent('UC-PatrolRobbery:lootLootable', lootData.netId) diff --git a/config.lua b/config.lua index 7d04d32..a0e69fe 100644 --- a/config.lua +++ b/config.lua @@ -5,7 +5,7 @@ Config.Debug = false Config.Integrations = { target = "ox_target", progressbar = "ox_lib", - notify = "ox_lib", + notify = "ox_lib", --esx, ox_lib inventory = "ox_inventory", } --Add new minigames here @@ -70,7 +70,7 @@ Config.Locations = { }, }, lootables = { - ["Safe"] = { + ["Safe"] = { model = "xm3_prop_xm3_safe_01a", --Find here https://forge.plebmasters.de/ lootAnimation = { dict = 'mini@safe_cracking', @@ -99,4 +99,4 @@ Config.Locations = { }, }, -} \ No newline at end of file +} diff --git a/fxmanifest.lua b/fxmanifest.lua index e251652..a9dbd77 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -25,4 +25,6 @@ dependencies { lua54 'yes' use_experimental_fxv2_oal 'yes' - +files { + 'locales/*.json' +} diff --git a/locales/en.json b/locales/en.json new file mode 100644 index 0000000..f28cce3 --- /dev/null +++ b/locales/en.json @@ -0,0 +1,9 @@ +{ + "name_robbery": "Construction Robbery", + "cooldown_robbery": "Lootable is on cooldown, please wait %s seconds.", + "work": "Working...", + "loot_name": "Loot %s", + "loot": "Looting %s ...", + "fail_loot": "You failed to loot the %s.", + "not_enought_space": "You cannot carry any more %s." +} \ No newline at end of file diff --git a/locales/pl.json b/locales/pl.json new file mode 100644 index 0000000..34712f9 --- /dev/null +++ b/locales/pl.json @@ -0,0 +1,9 @@ +{ + "name_robbery": "Napad na budowę", + "cooldown_robbery": "Jest pusty, poczekaj %s sekund.", + "work": "Pracowanie...", + "loot_name": "Łup %s", + "loot": "Przeszukiwanie %s ...", + "fail_loot": "Nie udało ci się ukraść %s.", + "not_enought_space": "Nie masz już miejsca w ekwipunku %s." +} \ No newline at end of file diff --git a/server/functions.lua b/server/functions.lua index cc6633c..ba8c3c3 100644 --- a/server/functions.lua +++ b/server/functions.lua @@ -1,7 +1,9 @@ +lib.locale() + function AddItem(item, amount, src) if Config.Integrations.inventory == "ox_inventory" then if not exports.ox_inventory:CanCarryItem(src, item, 1) then - NotifServer(src, "You cannot carry any more "..item..".") + NotifServer(src, locale('not_enought_space', item)) return end exports.ox_inventory:AddItem(src, item, amount) @@ -14,15 +16,16 @@ function NotifServer(src, msg) if Config.Integrations.notify == "ox_lib" then TriggerClientEvent('ox_lib:notify', src, { type = 'success', - title = 'Construction Robbery', + title = locale('name_robbery'), description = msg, duration = 5000, position = 'top-right' }) - return + elseif Config.Integrations.notify == "esx" then + TriggerClientEvent("ESX:Notify", src, "success", 3000, msg, locale('name_robbery')) + else + print("[ERROR] No Notify integration found.") end - print("[ERROR] No Notify integration found.") - end function CallPolice(coords) diff --git a/server/main.lua b/server/main.lua index c737c8f..69aac8d 100644 --- a/server/main.lua +++ b/server/main.lua @@ -56,7 +56,7 @@ RegisterNetEvent('UC-PatrolRobbery:lootLootable', function(netID) GiveRewards(l, src) else - NotifServer(src, "Lootable is on cooldown, please wait "..math.floor(l.cooldown / 1000).." seconds.") + NotifServer(src, locale('cooldown_robbery', math.floor(l.cooldown / 1000))) end break end