Properly formatted strings

This commit is contained in:
ElPumpo
2018-10-22 23:17:36 +02:00
parent ca85a1fff6
commit fb4887565c
11 changed files with 97 additions and 91 deletions
+15 -15
View File
@@ -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'
}
+24 -24
View File
@@ -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', ('<span style="color: green;">%s</span>'):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 .. ' - <span style="color:green;">$' .. item.price .. ' </span>',
realLabel = item.label,
value = item.name,
price = item.price
label = ('%s - <span style="color: green;">%s</span>'):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
+22 -22
View File
@@ -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 },
}
},
}
+7 -6
View File
@@ -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',
}
+5 -4
View File
@@ -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',
}
+5 -4
View File
@@ -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',
}
+2 -1
View File
@@ -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',
}
+2 -1
View File
@@ -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',
}
+2 -1
View File
@@ -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',
}
+2 -1
View File
@@ -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ą',
}
+11 -12
View File
@@ -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)