From 3960dd3a78a07b4024a348ac65c575601629cfaa Mon Sep 17 00:00:00 2001 From: ElPumpo Date: Thu, 10 Jan 2019 13:15:51 +0100 Subject: [PATCH] Security improvements --- locales/br.lua | 6 +++--- locales/en.lua | 6 +++--- locales/fr.lua | 6 +++--- server/main.lua | 30 ++++++++++++++++++++++-------- 4 files changed, 31 insertions(+), 17 deletions(-) diff --git a/locales/br.lua b/locales/br.lua index e2ecd080..2ba4f59c 100644 --- a/locales/br.lua +++ b/locales/br.lua @@ -23,10 +23,10 @@ Locales['br'] = { ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'Dirigindo em busca de ~y~passageiros', ['customer_found'] = 'Você ~g~encontrou~s~ um passageiro, dirija até o destino', - ['client_unconcious'] = 'Seu passageiro está ~r~insconsciente~w~. Procure por outro.', + ['client_unconcious'] = 'Seu passageiro está ~r~insconsciente~s~. Procure por outro.', ['arrive_dest'] = 'Você ~g~chegou~s~ ao seu destino', - ['take_me_to_near'] = '~w~Leve me para~y~ %s~w~, perto~y~ %s', - ['take_me_to'] = '~w~Leve me para~y~ %s', + ['take_me_to_near'] = '~s~Leve me para~y~ %s~s~, perto~y~ %s', + ['take_me_to'] = '~s~Leve me para~y~ %s', ['close_to_client'] = 'Você está perto do passageiro, aproximisse dele', ['return_to_veh'] = 'Volte para o seu veículo para continuar a missão', ['must_in_taxi'] = 'Você deve estar em um táxi para começar a missão', diff --git a/locales/en.lua b/locales/en.lua index ec09d19c..d5ed3ca4 100644 --- a/locales/en.lua +++ b/locales/en.lua @@ -22,14 +22,14 @@ Locales['en'] = { ['no_players_near'] = 'no players nearby', ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'driving in search of ~y~passengers', - ['customer_found'] = 'you have ~g~found~s~ a customer, drive until last', - ['client_unconcious'] = 'your client is ~r~unconscious~s~. Look for another one.', + ['customer_found'] = 'you have ~g~found~s~ a customer, get closer to them', + ['client_unconcious'] = 'your client is ~r~unconscious~s~, look for another one', ['arrive_dest'] = 'you have ~g~arrived~s~ at your destination', ['take_me_to_near'] = '~s~Take me to~y~ %s~s~, near ~y~%s', ['take_me_to'] = '~s~Take me to ~y~%s', ['close_to_client'] = 'you are too far from the client, get close to them', ['return_to_veh'] = 'please return to your vehicle to continue the mission', - ['must_in_taxi'] = 'you must be in a taxi to start the mission', + ['must_in_taxi'] = 'you must be in a ~y~taxi~s~ to start the mission', ['must_in_vehicle'] = 'you must be in a vehicle to begin the mission', ['have_earned'] = 'you have earned ~g~$%s~s~', ['comp_earned'] = '- your company has earned ~g~$%s~s~\n- you have earned ~g~$%s~s~', diff --git a/locales/fr.lua b/locales/fr.lua index e4b2ffa3..4d942293 100644 --- a/locales/fr.lua +++ b/locales/fr.lua @@ -23,10 +23,10 @@ Locales['fr'] = { ['start_job'] = 'start / stop driving NPC jobs', ['drive_search_pass'] = 'conduisez à la recherche de ~y~passagers', ['customer_found'] = 'vous avez ~g~trouvé~s~ un client, conduisez jusqu\'à ce dernier', - ['client_unconcious'] = 'votre client est ~r~inconscient~w~. Cherchez-en un autre.', + ['client_unconcious'] = 'votre client est ~r~inconscient~s~. Cherchez-en un autre.', ['arrive_dest'] = 'vous êtes ~g~arrivé~s~ à destination', - ['take_me_to_near'] = '~w~Emmenez-moi à~y~ %s~w~, près de~y~ %s', - ['take_me_to'] = '~w~Emmenez-moi à~y~ %s', + ['take_me_to_near'] = '~s~Emmenez-moi à~y~ %s~s~, près de~y~ %s', + ['take_me_to'] = '~s~Emmenez-moi à~y~ %s', ['close_to_client'] = 'vous êtes à proximité du client, approchez-vous de lui', ['return_to_veh'] = 'veuillez remonter dans votre véhicule pour continuer la mission', ['must_in_taxi'] = 'vous devez être dans un taxi pour commencer la mission', diff --git a/server/main.lua b/server/main.lua index 704f8043..ff8ec2a6 100644 --- a/server/main.lua +++ b/server/main.lua @@ -11,11 +11,17 @@ TriggerEvent('esx_society:registerSociety', 'taxi', 'Taxi', 'society_taxi', 'soc RegisterServerEvent('esx_taxijob:success') AddEventHandler('esx_taxijob:success', function() + local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name ~= 'taxi' then + print(('esx_taxijob: %s attempted to trigger success!'):format(xPlayer.identifier)) + return + end + math.randomseed(os.time()) - local xPlayer = ESX.GetPlayerFromId(source) - local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max) - local societyAccount = nil + local total = math.random(Config.NPCJobEarnings.min, Config.NPCJobEarnings.max) + local societyAccount if xPlayer.job.grade >= 3 then total = total * 2 @@ -25,16 +31,14 @@ AddEventHandler('esx_taxijob:success', function() societyAccount = account end) - if societyAccount ~= nil then - - local playerMoney = math.floor(total / 100 * 30) - local societyMoney = math.floor(total / 100 * 70) + if societyAccount then + local playerMoney = ESX.Math.Round(total / 100 * 30) + local societyMoney = ESX.Math.Round(total / 100 * 70) xPlayer.addMoney(playerMoney) societyAccount.addMoney(societyMoney) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('comp_earned', societyMoney, playerMoney)) - else xPlayer.addMoney(total) TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_earned', total)) @@ -45,6 +49,11 @@ end) RegisterServerEvent('esx_taxijob:getStockItem') AddEventHandler('esx_taxijob:getStockItem', function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) + + if xPlayer.job.name ~= 'taxi' then + print(('esx_taxijob: %s attempted to trigger getStockItem!'):format(xPlayer.identifier)) + return + end TriggerEvent('esx_addoninventory:getSharedInventory', 'society_taxi', function(inventory) local item = inventory.getItem(itemName) @@ -77,6 +86,11 @@ RegisterServerEvent('esx_taxijob:putStockItems') AddEventHandler('esx_taxijob:putStockItems', function(itemName, count) local xPlayer = ESX.GetPlayerFromId(source) + if xPlayer.job.name ~= 'taxi' then + print(('esx_taxijob: %s attempted to trigger putStockItems!'):format(xPlayer.identifier)) + return + end + TriggerEvent('esx_addoninventory:getSharedInventory', 'society_taxi', function(inventory) local item = inventory.getItem(itemName)