Merge pull request #12 from StockholmCityRP/master

Fixed exploits
This commit is contained in:
Don
2018-02-23 00:05:49 -08:00
committed by GitHub
7 changed files with 49 additions and 42 deletions
+2
View File
@@ -12,6 +12,7 @@ server_scripts {
'locales/en.lua',
'locales/fr.lua',
'locales/es.lua',
'locales/sv.lua',
'config.lua',
'server/main.lua'
}
@@ -23,6 +24,7 @@ client_scripts {
'locales/en.lua',
'locales/fr.lua',
'locales/es.lua',
'locales/sv.lua',
'config.lua',
'client/main.lua'
}
+7 -10
View File
@@ -37,7 +37,7 @@ function ShowBillsMenu()
'default', GetCurrentResourceName(), 'billing',
{
title = _U('invoices'),
align = 'top-left',
align = 'bottom-right',
elements = elements
},
function(data, menu)
@@ -63,13 +63,10 @@ end
-- Key controls
Citizen.CreateThread(function()
while true do
Wait(0)
if IsControlPressed(0, Keys["F7"]) and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') and (GetGameTimer() - GUI.Time) > 150 then
ShowBillsMenu()
GUI.Time = GetGameTimer()
end
end
Citizen.Wait(25)
if IsControlPressed(0, Keys["F7"]) and not ESX.UI.Menu.IsOpen('default', GetCurrentResourceName(), 'billing') and (GetGameTimer() - GUI.Time) > 150 then
ShowBillsMenu()
GUI.Time = GetGameTimer()
end
end
end)
+1 -1
View File
@@ -1,2 +1,2 @@
Config = {}
Config.Locale = 'fr'
Config.Locale = 'sv'
+1 -1
View File
@@ -1,4 +1,4 @@
USE `essentialmode`;
USE `fivem2337`;
CREATE TABLE `billing` (
+4 -3
View File
@@ -1,9 +1,10 @@
Locales['en'] = {
['invoices'] = 'invoices',
['received_invoice'] = 'you ~r~received~s~ an invoice',
['received_invoice'] = 'you have just ~r~received~s~ an invoice',
['paid_invoice'] = 'you ~g~paid~s~ an invoice of ~r~$',
['received_payment'] = 'you ~g~received~s~ a payment of ~r~$',
['player_not_logged'] = 'the player is not logged in',
['no_money'] = 'you do not have enough money to pay this bill',
['target_no_money'] = 'The player ~r~does not~w~ have enough money to pay the bill!',
['negative_bill'] = 'You cannot send negative bills!'
}
+10
View File
@@ -0,0 +1,10 @@
Locales['sv'] = {
['invoices'] = 'räkningar',
['received_invoice'] = 'du har ~y~mottagit~s~ en räkning',
['paid_invoice'] = 'du ~y~betalade~w~ precis en räkning på ~g~$',
['received_payment'] = 'du har ~y~mottagit~w~ en räkning på ~g~$',
['player_not_logged'] = 'spelaren är inte online',
['no_money'] = 'du har ~r~inte råd~w~ för att kunna betala räkningen',
['target_no_money'] = 'Spelaren har ~r~inte råd~w~ för att betala räkningen',
['negative_bill'] = 'Du kan inte skicka negativa räkningar!'
}
+24 -27
View File
@@ -6,12 +6,15 @@ RegisterServerEvent('esx_billing:sendBill')
AddEventHandler('esx_billing:sendBill', function(playerId, sharedAccountName, label, amount)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayer = ESX.GetPlayerFromId(_source)
local xPlayers = ESX.GetPlayers()
TriggerEvent('esx_addonaccount:getSharedAccount', sharedAccountName, function(account)
if account == nil then
if amount < 0 then
print('esx_billing: ' .. GetPlayerName(_source) .. ' tried sending a negative bill!')
TriggerClientEvent('esx:showNotification', _source, _U('negative_bill'))
elseif account == nil then
for i=1, #xPlayers, 1 do
@@ -37,9 +40,7 @@ AddEventHandler('esx_billing:sendBill', function(playerId, sharedAccountName, la
break
end
end
else
for i=1, #xPlayers, 1 do
local xPlayer2 = ESX.GetPlayerFromId(xPlayers[i])
@@ -64,9 +65,7 @@ AddEventHandler('esx_billing:sendBill', function(playerId, sharedAccountName, la
break
end
end
end
end)
end)
@@ -166,30 +165,28 @@ ESX.RegisterServerCallback('esx_billing:payBill', function(source, cb, id)
end
else
TriggerEvent('esx_addonaccount:getSharedAccount', target, function(account)
MySQL.Async.execute(
'DELETE from billing WHERE id = @id',
{
['@id'] = id
},
function(rowsChanged)
xPlayer.removeMoney(amount)
account.addMoney(amount)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice') .. amount)
if foundPlayer ~= nil then
TriggerClientEvent('esx:showNotification', foundPlayer.source, _U('received_payment') .. amount)
end
if xPlayer.get('money') >= amount then
MySQL.Async.execute(
'DELETE from billing WHERE id = @id',
{
['@id'] = id
},
function(rowsChanged)
xPlayer.removeMoney(amount)
account.addMoney(amount)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('paid_invoice') .. amount)
if foundPlayer ~= nil then
TriggerClientEvent('esx:showNotification', foundPlayer.source, _U('received_payment') .. amount)
end
cb()
end)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('no_money'))
if foundPlayer ~= nil then
TriggerClientEvent('esx:showNotification', foundPlayer.source, _U('target_no_money'))
end
)
end
end)
end