Added log level to print uses, and change formatting

This commit is contained in:
ElPumpo
2020-01-03 13:55:23 +01:00
parent ffa05600a4
commit 2140f8628c
4 changed files with 49 additions and 67 deletions
+36 -57
View File
@@ -22,8 +22,6 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
if money >= 0 then
self.player.setMoney(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 cash balance)'):format(self.identifier))
end
end
@@ -36,8 +34,6 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
if money >= 0 then
self.player.setBankBalance(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 bank balance)'):format(self.identifier))
end
end
@@ -69,38 +65,30 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
if money >= 0 then
self.player.addMoney(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 cash balance)'):format(self.identifier))
end
end
self.removeMoney = function(money)
money = ESX.Math.Round(money)
if money >= 0 then
if money > 0 then
self.player.removeMoney(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 cash balance)'):format(self.identifier))
end
end
self.addBank = function(money)
money = ESX.Math.Round(money)
if money >= 0 then
if money > 0 then
self.player.addBank(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 bank balance)'):format(self.identifier))
end
end
self.removeBank = function(money)
money = ESX.Math.Round(money)
if money >= 0 then
if money > 0 then
self.player.removeBank(money)
else
print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 bank balance)'):format(self.identifier))
end
end
@@ -261,64 +249,55 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
end
self.setAccountMoney = function(acc, money)
if money < 0 then
print(('es_extended: %s attempted exploiting! (reason: player tried setting -1 account balance)'):format(self.identifier))
return
end
if money >= 0 then
local account = self.getAccount(acc)
local account = self.getAccount(acc)
if account then
local prevMoney = account.money
local newMoney = ESX.Math.Round(money)
if account then
local prevMoney = account.money
local newMoney = ESX.Math.Round(money)
account.money = newMoney
account.money = newMoney
if acc == 'bank' then
self.set('bank', newMoney)
end
if acc == 'bank' then
self.set('bank', newMoney)
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
end
self.addAccountMoney = function(acc, money)
if money < 0 then
print(('es_extended: %s attempted exploiting! (reason: player tried adding -1 account balance)'):format(self.identifier))
return
end
if money > 0 then
local account = self.getAccount(acc)
local account = self.getAccount(acc)
if account then
local newMoney = account.money + ESX.Math.Round(money)
account.money = newMoney
if acc == 'bank' then
self.set('bank', newMoney)
if account then
local newMoney = account.money + ESX.Math.Round(money)
account.money = newMoney
if acc == 'bank' then
self.set('bank', newMoney)
end
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
end
self.removeAccountMoney = function(acc, money)
if money < 0 then
print(('es_extended: %s attempted exploiting! (reason: player tried removing -1 account balance)'):format(self.identifier))
return
end
if money > 0 then
local account = self.getAccount(acc)
local account = self.getAccount(acc)
if account then
local newMoney = account.money - ESX.Math.Round(money)
account.money = newMoney
if acc == 'bank' then
self.set('bank', newMoney)
if account then
local newMoney = account.money - ESX.Math.Round(money)
account.money = newMoney
if acc == 'bank' then
self.set('bank', newMoney)
end
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
TriggerClientEvent('esx:setAccountMoney', self.source, account)
end
end
@@ -442,7 +421,7 @@ function CreateExtendedPlayer(player, accounts, inventory, job, loadout, name, l
TriggerEvent('esx:setJob', self.source, self.job, lastJob)
TriggerClientEvent('esx:setJob', self.source, self.job)
else
print(('es_extended: ignoring setJob for %s due to job not found!'):format(self.source))
print(('[es_extended] [^3WARNING^7] Ignoring invalid .setJob() usage for "%s"'):format(self.identifier))
end
end
+7 -3
View File
@@ -43,16 +43,18 @@ MySQL.ready(function()
if ESX.Jobs[result2[i].job_name] then
ESX.Jobs[result2[i].job_name].grades[tostring(result2[i].grade)] = result2[i]
else
print(('es_extended: invalid job "%s" from table job_grades ignored!'):format(result2[i].job_name))
print(('[es_extended] [^3WARNING^7] Invalid job "%s" from table job_grades ignored'):format(result2[i].job_name))
end
end
for k,v in pairs(ESX.Jobs) do
if next(v.grades) == nil then
ESX.Jobs[v.name] = nil
print(('es_extended: ignoring job "%s" due to missing job grades!'):format(v.name))
print(('[es_extended] [^3WARNING^7] Ignoring job "%s" due to missing job grades'):format(v.name))
end
end
print('[es_extended] [^2INFO^7] ESX developed by ESX-Org has been initialized')
end)
AddEventHandler('esx:playerLoaded', function(source)
@@ -78,7 +80,9 @@ end)
RegisterServerEvent('esx:clientLog')
AddEventHandler('esx:clientLog', function(msg)
RconPrint(msg .. "\n")
if Config.EnableDebug then
print(('[es_extended] [^2TRACE^7] %s'):format(msg))
end
end)
RegisterServerEvent('esx:triggerServerCallback')
+4 -5
View File
@@ -1,6 +1,6 @@
ESX.Trace = function(str)
if Config.EnableDebug then
print('ESX> ' .. str)
print(('[es_extended] [^2TRACE^7] %s'):format(str))
end
end
@@ -32,7 +32,7 @@ ESX.TriggerServerCallback = function(name, requestId, source, cb, ...)
if ESX.ServerCallbacks[name] ~= nil then
ESX.ServerCallbacks[name](source, cb, ...)
else
print('es_extended: TriggerServerCallback => [' .. name .. '] does not exist')
print(('[es_extended] [^3WARNING^7] Server callback "%s" does not exist. Make sure that the server sided file really is loading, an error in that file might cause it to not load.'):format(name))
end
end
@@ -88,7 +88,7 @@ ESX.SavePlayer = function(xPlayer, cb)
end)
Async.parallel(asyncTasks, function(results)
RconPrint('[SAVED] ' .. xPlayer.name .. "^7\n")
print(('[es_extended] [^2INFO^7] Saved %s'):format(xPlayer.getName()))
if cb ~= nil then
cb()
@@ -108,8 +108,7 @@ ESX.SavePlayers = function(cb)
end
Async.parallelLimit(asyncTasks, 8, function(results)
RconPrint('[SAVED] All players' .. "\n")
print(('[es_extended] [^2INFO^7] Saved %s player(s)'):format(#xPlayers))
if cb ~= nil then
cb()
end
+2 -2
View File
@@ -66,7 +66,7 @@ AddEventHandler('es:playerLoaded', function(source, _player)
canRemove = item.canRemove
})
else
print(('es_extended: invalid item "%s" ignored!'):format(v.item))
print(('[es_extended] [^3WARNING^7] Ignoring invalid item "%s" for "%s"'):format(v.item, player.getIdentifier()))
end
end
@@ -147,7 +147,7 @@ AddEventHandler('es:playerLoaded', function(source, _player)
userData.job.skin_female = json.decode(gradeObject.skin_female)
end
else
print(('es_extended: %s had an unknown job [job: %s, grade: %s], setting as unemployed!'):format(player.getIdentifier(), job, grade))
print(('[es_extended] [^3WARNING^7] Ignoring invalid job for %s [job: %s, grade: %s]'):format(player.getIdentifier(), job, grade))
local job, grade = 'unemployed', '0'
local jobObject, gradeObject = ESX.Jobs[job], ESX.Jobs[job].grades[grade]