From ca85a1fff6ee5da5b7d72105f8f15643cba6cae5 Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Mon, 22 Oct 2018 22:50:43 +0200 Subject: [PATCH] Initial cleanup --- client/main.lua | 37 +++++++++++++++++++++++-------------- locales/br.lua | 7 ++++--- locales/de.lua | 7 ++++--- locales/en.lua | 6 ++---- locales/es.lua | 17 +++++++++-------- locales/fi.lua | 4 +--- locales/fr.lua | 6 ++---- locales/pl.lua | 4 +--- server/main.lua | 32 +++++++++++++++----------------- 9 files changed, 61 insertions(+), 59 deletions(-) diff --git a/client/main.lua b/client/main.lua index 21fd1b0a..3ef1c599 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1,3 +1,15 @@ +local Keys = { + ["ESC"] = 322, ["F1"] = 288, ["F2"] = 289, ["F3"] = 170, ["F5"] = 166, ["F6"] = 167, ["F7"] = 168, ["F8"] = 169, ["F9"] = 56, ["F10"] = 57, + ["~"] = 243, ["1"] = 157, ["2"] = 158, ["3"] = 160, ["4"] = 164, ["5"] = 165, ["6"] = 159, ["7"] = 161, ["8"] = 162, ["9"] = 163, ["-"] = 84, ["="] = 83, ["BACKSPACE"] = 177, + ["TAB"] = 37, ["Q"] = 44, ["W"] = 32, ["E"] = 38, ["R"] = 45, ["T"] = 245, ["Y"] = 246, ["U"] = 303, ["P"] = 199, ["["] = 39, ["]"] = 40, ["ENTER"] = 18, + ["CAPS"] = 137, ["A"] = 34, ["S"] = 8, ["D"] = 9, ["F"] = 23, ["G"] = 47, ["H"] = 74, ["K"] = 311, ["L"] = 182, + ["LEFTSHIFT"] = 21, ["Z"] = 20, ["X"] = 73, ["C"] = 26, ["V"] = 0, ["B"] = 29, ["N"] = 249, ["M"] = 244, [","] = 82, ["."] = 81, + ["LEFTCTRL"] = 36, ["LEFTALT"] = 19, ["SPACE"] = 22, ["RIGHTCTRL"] = 70, + ["HOME"] = 213, ["PAGEUP"] = 10, ["PAGEDOWN"] = 11, ["DELETE"] = 178, + ["LEFT"] = 174, ["RIGHT"] = 175, ["TOP"] = 27, ["DOWN"] = 173, + ["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118 +} + ESX = nil local HasAlreadyEnteredMarker = false local LastZone = nil @@ -31,12 +43,11 @@ end) function OpenBuyLicenseMenu(zone) ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_license', - { + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop_license', { title = _U('buy_license'), elements = { { label = _U('yes') .. ' ($' .. Config.LicensePrice .. ')', value = 'yes' }, - { label = _U('no'), value = 'no' }, + { label = _U('no'), value = 'no' } } }, function (data, menu) if data.current.value == 'yes' then @@ -45,8 +56,7 @@ function OpenBuyLicenseMenu(zone) menu.close() end, function (data, menu) menu.close() - end - ) + end) end function OpenShopMenu(zone) @@ -62,21 +72,21 @@ function OpenShopMenu(zone) price = item.price }) end + ESX.UI.Menu.CloseAll() - ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', - { + ESX.UI.Menu.Open('default', GetCurrentResourceName(), 'shop', { title = _U('shop'), elements = elements }, function(data, menu) TriggerServerEvent('esx_weashop:buyItem', data.current.value, data.current.price, zone) end, function(data, menu) menu.close() + CurrentAction = 'shop_menu' CurrentActionMsg = _U('shop_menu') CurrentActionData = {zone = zone} - end - ) + end) end AddEventHandler('esx_weashop:hasEnteredMarker', function(zone) @@ -96,11 +106,13 @@ Citizen.CreateThread(function() if v.legal==0 then 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) SetBlipDisplay(blip, 4) SetBlipScale (blip, 1.0) SetBlipColour (blip, 2) SetBlipAsShortRange(blip, true) + BeginTextCommandSetBlipName("STRING") AddTextComponentString(_U('map_blip')) EndTextCommandSetBlipName(blip) @@ -159,12 +171,9 @@ Citizen.CreateThread(function() while true do Citizen.Wait(0) if CurrentAction ~= nil then + ESX.ShowHelpNotification(CurrentActionMsg) - SetTextComponentFormat('STRING') - AddTextComponentString(CurrentActionMsg) - DisplayHelpTextFromStringLabel(0, 0, 1, -1) - - if IsControlJustReleased(0, 38) then + if IsControlJustReleased(0, Keys['E']) then if CurrentAction == 'shop_menu' then if Config.EnableLicense == true then diff --git a/locales/br.lua b/locales/br.lua index 2c67d44d..e35d36b6 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -1,10 +1,11 @@ Locales ['br'] = { - - ['buy'] = 'Você comprou', + ['buy_license'] = 'buy weapon license?', + ['yes'] = 'yes', + ['no'] = 'no', + ['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', - } diff --git a/locales/de.lua b/locales/de.lua index d18dc9a1..4f1f3821 100644 --- a/locales/de.lua +++ b/locales/de.lua @@ -1,10 +1,11 @@ Locales ['de'] = { - - ['buy'] = 'du kaufst', + ['buy_license'] = 'buy weapon license?', + ['yes'] = 'yes', + ['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', - } diff --git a/locales/en.lua b/locales/en.lua index e0fab708..f61744b7 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -1,13 +1,11 @@ Locales ['en'] = { - - ['buy_license'] = 'buy a license?', + ['buy_license'] = 'buy weapon license?', ['yes'] = 'yes', ['no'] = 'no', - ['buy'] = 'you bought', + ['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', - } diff --git a/locales/es.lua b/locales/es.lua index de77e82e..f3e8e6a4 100644 --- a/locales/es.lua +++ b/locales/es.lua @@ -1,10 +1,11 @@ Locales ['es'] = { - - ['buy'] = 'Has comprado ~b~1 ', - ['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.', - ['map_blip'] = 'Arsenal', - + ['buy_license'] = 'buy weapon license?', + ['yes'] = 'yes', + ['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.', + ['map_blip'] = 'arsenal', } diff --git a/locales/fi.lua b/locales/fi.lua index 5e897af2..99824514 100644 --- a/locales/fi.lua +++ b/locales/fi.lua @@ -1,13 +1,11 @@ Locales ['fi'] = { - ['buy_license'] = 'osta lisenssi?', ['yes'] = 'kyllä', ['no'] = 'ei', - ['buy'] = 'sinä ostit', + ['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.', ['map_blip'] = 'asekauppa', - } diff --git a/locales/fr.lua b/locales/fr.lua index 8f9b2862..23a4343f 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -1,13 +1,11 @@ Locales ['fr'] = { - - ['buy_license'] = 'acheter une license ?', + ['buy_license'] = 'acheter une license?', ['yes'] = 'oui', ['no'] = 'non', - ['buy'] = 'vous avez acheté ~b~1x ', + ['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.', ['map_blip'] = 'armurerie', - } diff --git a/locales/pl.lua b/locales/pl.lua index bdbe4278..ba7bd450 100644 --- a/locales/pl.lua +++ b/locales/pl.lua @@ -1,13 +1,11 @@ Locales ['pl'] = { - ['buy_license'] = 'czy chcesz kupić licencję?', ['yes'] = 'tak', ['no'] = 'nie', - ['buy'] = 'kupiłeś/aś', + ['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.', ['map_blip'] = 'sklep z bronią', - } diff --git a/server/main.lua b/server/main.lua index 672e113d..ecc2859b 100644 --- a/server/main.lua +++ b/server/main.lua @@ -3,16 +3,16 @@ local ItemsLabels = {} TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end) -function LoadLicenses (source) - TriggerEvent('esx_license:getLicenses', source, function (licenses) - TriggerClientEvent('esx_weashop:loadLicenses', source, licenses) - end) +function LoadLicenses(source) + TriggerEvent('esx_license:getLicenses', source, function (licenses) + TriggerClientEvent('esx_weashop:loadLicenses', source, licenses) + end) end if Config.EnableLicense == true then - AddEventHandler('esx:playerLoaded', function (source) - LoadLicenses(source) - end) + AddEventHandler('esx:playerLoaded', function (source) + LoadLicenses(source) + end) end RegisterServerEvent('esx_weashop:buyLicense') @@ -23,7 +23,7 @@ AddEventHandler('esx_weashop:buyLicense', function () if xPlayer.get('money') >= Config.LicensePrice then xPlayer.removeMoney(Config.LicensePrice) - TriggerEvent('esx_license:addLicense', _source, 'weapon', function () + TriggerEvent('esx_license:addLicense', _source, 'weapon', function() LoadLicenses(_source) end) else @@ -32,9 +32,9 @@ AddEventHandler('esx_weashop:buyLicense', function () end) ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb) - MySQL.Async.fetchAll('SELECT * FROM weashops', - {}, function(result) + MySQL.Async.fetchAll('SELECT * FROM weashops', {}, function(result) local shopItems = {} + for i=1, #result, 1 do if shopItems[result[i].name] == nil then @@ -50,9 +50,7 @@ ESX.RegisterServerCallback('esx_weashop:requestDBItems', function(source, cb) end cb(shopItems) - - end - ) + end) end) RegisterServerEvent('esx_weashop:buyItem') @@ -61,19 +59,19 @@ AddEventHandler('esx_weashop:buyItem', function(itemName, price, zone) local xPlayer = ESX.GetPlayerFromId(source) local account = xPlayer.getAccount('black_money') - if zone=="BlackWeashop" then + 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')) end else - if xPlayer.get('money') >= price then + 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')) end