From fb4887565c2f8fe5a5376468ddd03eaeda941e4e Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 22 Oct 2018 23:17:36 +0200 Subject: [PATCH] Properly formatted strings --- __resource.lua | 30 +++++++++++++++--------------- client/main.lua | 48 ++++++++++++++++++++++++------------------------ config.lua | 44 ++++++++++++++++++++++---------------------- locales/br.lua | 13 +++++++------ locales/de.lua | 9 +++++---- locales/en.lua | 9 +++++---- locales/es.lua | 3 ++- locales/fi.lua | 3 ++- locales/fr.lua | 3 ++- locales/pl.lua | 3 ++- server/main.lua | 23 +++++++++++------------ 11 files changed, 97 insertions(+), 91 deletions(-) diff --git a/__resource.lua b/__resource.lua index e61bc142..1b141e5c 100644 --- a/__resource.lua +++ b/__resource.lua @@ -1,9 +1,23 @@ resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937' -description 'ESX Weaponshop' +description 'ESX Weapon Shop' version '1.0.2' +server_scripts { + '@mysql-async/lib/MySQL.lua', + '@es_extended/locale.lua', + 'locales/de.lua', + 'locales/br.lua', + 'locales/en.lua', + 'locales/fi.lua', + 'locales/fr.lua', + 'locales/es.lua', + 'locales/pl.lua', + 'config.lua', + 'server/main.lua' +} + client_scripts { '@es_extended/locale.lua', 'locales/de.lua', @@ -16,17 +30,3 @@ client_scripts { 'config.lua', 'client/main.lua' } - -server_scripts { - '@es_extended/locale.lua', - 'locales/de.lua', - 'locales/br.lua', - 'locales/en.lua', - 'locales/fi.lua', - 'locales/fr.lua', - 'locales/es.lua', - 'locales/pl.lua', - '@mysql-async/lib/MySQL.lua', - 'config.lua', - 'server/main.lua' -} diff --git a/client/main.lua b/client/main.lua index 3ef1c599..63b85064 100644 --- a/client/main.lua +++ b/client/main.lua @@ -23,16 +23,7 @@ Citizen.CreateThread(function() TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) Citizen.Wait(0) end -end) -RegisterNetEvent('esx_weashop:loadLicenses') -AddEventHandler('esx_weashop:loadLicenses', function (licenses) - for i = 1, #licenses, 1 do - Licenses[licenses[i].type] = true - end -end) - -AddEventHandler('onClientMapStart', function() ESX.TriggerServerCallback('esx_weashop:requestDBItems', function(ShopItems) for k,v in pairs(ShopItems) do Config.Zones[k].Items = v @@ -40,13 +31,20 @@ AddEventHandler('onClientMapStart', function() end) end) +RegisterNetEvent('esx_weashop:loadLicenses') +AddEventHandler('esx_weashop:loadLicenses', function(licenses) + for i = 1, #licenses, 1 do + Licenses[licenses[i].type] = true + end +end) + function OpenBuyLicenseMenu(zone) ESX.UI.Menu.CloseAll() ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_license', { title = _U('buy_license'), elements = { - { label = _U('yes') .. ' ($' .. Config.LicensePrice .. ')', value = 'yes' }, + { label = _U('yes', ('%s'):format(ESX.Math.GroupDigits(_U('shop_menu_item', Config.LicensePrice)))), value = 'yes' }, { label = _U('no'), value = 'no' } } }, function (data, menu) @@ -66,10 +64,9 @@ function OpenShopMenu(zone) local item = Config.Zones[zone].Items[i] table.insert(elements, { - label = item.label .. ' - $' .. item.price .. ' ', - realLabel = item.label, - value = item.name, - price = item.price + label = ('%s - %s'):format(item.label, ESX.Math.GroupDigits(_U('shop_menu_item', item.price))), + weaponName = item.item, + price = item.price }) end @@ -79,20 +76,20 @@ function OpenShopMenu(zone) title = _U('shop'), elements = elements }, function(data, menu) - TriggerServerEvent('esx_weashop:buyItem', data.current.value, data.current.price, zone) + TriggerServerEvent('esx_weashop:buyItem', data.current.weaponName, data.current.price, zone) end, function(data, menu) menu.close() CurrentAction = 'shop_menu' CurrentActionMsg = _U('shop_menu') - CurrentActionData = {zone = zone} + CurrentActionData = { zone = zone } end) end AddEventHandler('esx_weashop:hasEnteredMarker', function(zone) CurrentAction = 'shop_menu' CurrentActionMsg = _U('shop_menu') - CurrentActionData = {zone = zone} + CurrentActionData = { zone = zone } end) AddEventHandler('esx_weashop:hasExitedMarker', function(zone) @@ -107,10 +104,10 @@ Citizen.CreateThread(function() for i = 1, #v.Pos, 1 do local blip = AddBlipForCoord(v.Pos[i].x, v.Pos[i].y, v.Pos[i].z) - SetBlipSprite (blip, 154) + SetBlipSprite (blip, 110) SetBlipDisplay(blip, 4) SetBlipScale (blip, 1.0) - SetBlipColour (blip, 2) + SetBlipColour (blip, 81) SetBlipAsShortRange(blip, true) BeginTextCommandSetBlipName("STRING") @@ -124,8 +121,10 @@ end) -- Display markers Citizen.CreateThread(function() while true do - Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + Citizen.Wait(0) + + local coords = GetEntityCoords(PlayerPedId()) + for k,v in pairs(Config.Zones) do for i = 1, #v.Pos, 1 do if(Config.Type ~= -1 and GetDistanceBetweenCoords(coords, v.Pos[i].x, v.Pos[i].y, v.Pos[i].z, true) < Config.DrawDistance) then @@ -140,7 +139,8 @@ end) Citizen.CreateThread(function() while true do Citizen.Wait(0) - local coords = GetEntityCoords(GetPlayerPed(-1)) + + local coords = GetEntityCoords(PlayerPedId()) local isInMarker = false local currentZone = nil @@ -170,13 +170,13 @@ end) Citizen.CreateThread(function() while true do Citizen.Wait(0) + if CurrentAction ~= nil then ESX.ShowHelpNotification(CurrentActionMsg) if IsControlJustReleased(0, Keys['E']) then - if CurrentAction == 'shop_menu' then - if Config.EnableLicense == true then + if Config.EnableLicense then if Licenses['weapon'] ~= nil or Config.Zones[CurrentActionData.zone].legal == 1 then OpenShopMenu(CurrentActionData.zone) else diff --git a/config.lua b/config.lua index cbe06869..ab01d636 100644 --- a/config.lua +++ b/config.lua @@ -9,29 +9,29 @@ Config.LicensePrice = 5000 Config.Zones = { - GunShop = { - legal = 0, - Items = {}, - Pos = { - { x = -662.180, y = -934.961, z = 20.829 }, - { x = 810.25, y = -2157.60, z = 28.62 }, - { x = 1693.44, y = 3760.16, z = 33.71 }, - { x = -330.24, y = 6083.88, z = 30.45 }, - { x = 252.63, y = -50.00, z = 68.94 }, - { x = 22.09, y = -1107.28, z = 28.80 }, - { x = 2567.69, y = 294.38, z = 107.73 }, - { x = -1117.58, y = 2698.61, z = 17.55 }, - { x = 842.44, y = -1033.42, z = 27.19 }, + GunShop = { + legal = 0, + Items = {}, + Pos = { + { x = -662.180, y = -934.961, z = 20.829 }, + { x = 810.25, y = -2157.60, z = 28.62 }, + { x = 1693.44, y = 3760.16, z = 33.71 }, + { x = -330.24, y = 6083.88, z = 30.45 }, + { x = 252.63, y = -50.00, z = 68.94 }, + { x = 22.09, y = -1107.28, z = 28.80 }, + { x = 2567.69, y = 294.38, z = 107.73 }, + { x = -1117.58, y = 2698.61, z = 17.55 }, + { x = 842.44, y = -1033.42, z = 27.19 }, - } - }, + } + }, - BlackWeashop = { - legal = 1, - Items = {}, - Pos = { - { x = -1306.239, y = -394.018, z = 35.695 }, - } - }, + BlackWeashop = { + legal = 1, + Items = {}, + Pos = { + { x = -1306.239, y = -394.018, z = 35.695 }, + } + }, } diff --git a/locales/br.lua b/locales/br.lua index e35d36b6..d4e9add3 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,11 +1,12 @@ Locales ['br'] = { ['buy_license'] = 'buy weapon license?', - ['yes'] = 'yes', + ['yes'] = '%s', ['no'] = 'no', - ['buy'] = 'Você comprou %s', - ['not_enough_black'] = 'Você não tem dinheiro sujo suficiente', + ['buy'] = 'você comprou %s', + ['not_enough_black'] = 'você não tem dinheiro sujo suficiente', ['not_enough'] = 'você não tem dinheiro suficiente', - ['shop'] = 'Comprar', - ['shop_menu'] = 'Pressione ~INPUT_CONTEXT~ para comprar armas.', - ['map_blip'] = 'Loja de Armas', + ['shop'] = 'comprar', + ['shop_menu'] = 'pressione ~INPUT_CONTEXT~ para comprar armas.', + ['shop_menu_item'] = 'R$%s', + ['map_blip'] = 'loja de Armas', } diff --git a/locales/de.lua b/locales/de.lua index 4f1f3821..070f3a7e 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,11 +1,12 @@ Locales ['de'] = { ['buy_license'] = 'buy weapon license?', - ['yes'] = 'yes', + ['yes'] = '%s', ['no'] = 'no', ['buy'] = 'du kaufst %s', ['not_enough_black'] = 'du hast nicht genug Schwarzgeld', ['not_enough'] = 'du hast nicht genug Geld', - ['shop'] = 'Geschäft', - ['shop_menu'] = 'Drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', - ['map_blip'] = 'Waffenladen', + ['shop'] = 'geschäft', + ['shop_menu'] = 'drücke ~INPUT_CONTEXT~ um auf das Geschäft zuzugreifen.', + ['shop_menu_item'] = '%s EUR', + ['map_blip'] = 'waffenladen', } diff --git a/locales/en.lua b/locales/en.lua index f61744b7..cd95640e 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,11 +1,12 @@ Locales ['en'] = { ['buy_license'] = 'buy weapon license?', - ['yes'] = 'yes', + ['yes'] = '%s', ['no'] = 'no', ['buy'] = 'you bought %s', ['not_enough_black'] = 'you do not have enough dirty money', ['not_enough'] = 'you do not have enough money', - ['shop'] = 'shop', - ['shop_menu'] = 'Press ~INPUT_CONTEXT~ to access the shop.', - ['map_blip'] = 'gun shop', + ['shop'] = 'weapon shop', + ['shop_menu'] = 'press ~INPUT_CONTEXT~ to access the ~y~weapon store~s~.', + ['shop_menu_item'] = '$%s', + ['map_blip'] = 'weapon shop', } diff --git a/locales/es.lua b/locales/es.lua index f3e8e6a4..47d20ab2 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -1,11 +1,12 @@ Locales ['es'] = { ['buy_license'] = 'buy weapon license?', - ['yes'] = 'yes', + ['yes'] = '%s', ['no'] = 'no', ['buy'] = 'has comprado %s', ['not_enough_black'] = 'usted no tiene ~r~suficiente~s~ dinero negro', ['not_enough'] = 'usted no tiene ~r~suficiente~s~ dinero', ['shop'] = 'tienda', ['shop_menu'] = 'presione ~INPUT_CONTEXT~ para acceder a la tienda.', + ['shop_menu_item'] = '%s EUR', ['map_blip'] = 'arsenal', } diff --git a/locales/fi.lua b/locales/fi.lua index 99824514..fa1a60f2 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,11 +1,12 @@ Locales ['fi'] = { ['buy_license'] = 'osta lisenssi?', - ['yes'] = 'kyllä', + ['yes'] = '%s', ['no'] = 'ei', ['buy'] = 'sinä ostit %s', ['not_enough_black'] = 'ei tarpeeksi likaista rahaa', ['not_enough'] = 'sinulla ei ole tarpeeksi rahaa', ['shop'] = 'kauppa', ['shop_menu'] = 'paina ~INPUT_CONTEXT~ avataksesi kauppa ikkuna.', + ['shop_menu_item'] = '%s EUR', ['map_blip'] = 'asekauppa', } diff --git a/locales/fr.lua b/locales/fr.lua index 23a4343f..fbdbff49 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,11 +1,12 @@ Locales ['fr'] = { ['buy_license'] = 'acheter une license?', - ['yes'] = 'oui', + ['yes'] = '%s', ['no'] = 'non', ['buy'] = 'vous avez acheté %s', ['not_enough_black'] = 'Vous n\'avez ~r~pas assez~s~ d\'argent sale', ['not_enough'] = 'vous n\'avez ~r~pas assez~s~ d\'argent', ['shop'] = 'magasin', ['shop_menu'] = 'appuyez sur ~INPUT_CONTEXT~ pour accéder au magasin.', + ['shop_menu_item'] = '%s EUR', ['map_blip'] = 'armurerie', } diff --git a/locales/pl.lua b/locales/pl.lua index ba7bd450..d52dc9aa 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -1,11 +1,12 @@ Locales ['pl'] = { ['buy_license'] = 'czy chcesz kupić licencję?', - ['yes'] = 'tak', + ['yes'] = '%s', ['no'] = 'nie', ['buy'] = 'kupiłeś/aś %s', ['not_enough_black'] = 'nie masz wystarczająco brudnej kasy', ['not_enough'] = 'nie masz wystarczająco pieniędzy', ['shop'] = 'sklep', ['shop_menu'] = 'Wciśnij ~INPUT_CONTEXT~ aby otworzyć sklep.', + ['shop_menu_item'] = '%s PLN', ['map_blip'] = 'sklep z bronią', } diff --git a/server/main.lua b/server/main.lua index ecc2859b..7412e593 100644 --- a/server/main.lua +++ b/server/main.lua @@ -20,7 +20,7 @@ AddEventHandler('esx_weashop:buyLicense', function () local _source = source local xPlayer = ESX.GetPlayerFromId(source) - if xPlayer.get('money') >= Config.LicensePrice then + if xPlayer.getMoney() >= Config.LicensePrice then xPlayer.removeMoney(Config.LicensePrice) TriggerEvent('esx_license:addLicense', _source, 'weapon', function() @@ -37,12 +37,12 @@ ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb) for i=1, #result, 1 do - if shopItems[result[i].name] == nil then - shopItems[result[i].name] = {} + if shopItems[result[i].zone] == nil then + shopItems[result[i].zone] = {} end - table.insert(shopItems[result[i].name], { - name = result[i].item, + table.insert(shopItems[result[i].zone], { + item = result[i].item, price = result[i].price, label = ESX.GetWeaponLabel(result[i].item) }) @@ -55,25 +55,24 @@ end) RegisterServerEvent('esx_weashop:buyItem') AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone) - local _source = source - local xPlayer = ESX.GetPlayerFromId(source) + local xPlayer = ESX.GetPlayerFromId(source) local account = xPlayer.getAccount('black_money') - + if zone == "BlackWeashop" then if account.money >= price then xPlayer.removeAccountMoney('black_money', price) xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(itemName))) + TriggerClientEvent('esx:showNotification', source, _U('buy', ESX.GetWeaponLabel(itemName))) else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough_black')) + TriggerClientEvent('esx:showNotification', source, _U('not_enough_black')) end else if xPlayer.getMoney() >= price then xPlayer.removeMoney(price) xPlayer.addWeapon(itemName, 42) - TriggerClientEvent('esx:showNotification', _source, _U('buy', ESX.GetWeaponLabel(itemName))) + TriggerClientEvent('esx:showNotification', source, _U('buy', ESX.GetWeaponLabel(itemName))) else - TriggerClientEvent('esx:showNotification', _source, _U('not_enough')) + TriggerClientEvent('esx:showNotification', source, _U('not_enough')) end end end)