feat: simply funcref check

This commit is contained in:
Zerio
2025-01-07 07:20:53 +01:00
parent 8660c98d49
commit 8ab5f76bdf
3 changed files with 54 additions and 36 deletions
+22 -18
View File
@@ -399,26 +399,32 @@ function PaycheckInterval()
if next(QBCore.Players) then
for _, Player in pairs(QBCore.Players) do
if Player then
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades'][tostring(Player.PlayerData.job.grade.level)].payment
local payment = QBShared.Jobs[Player.PlayerData.job.name]['grades']
[tostring(Player.PlayerData.job.grade.level)].payment
if not payment then payment = Player.PlayerData.job.payment end
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
if QBCore.Config.Money.PayCheckSociety then
local account = exports['qb-banking']:GetAccountBalance(Player.PlayerData.job.name)
if account ~= 0 then -- Checks if player is employed by a society
if account < payment then -- Checks if company has enough money to pay society
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source,
Lang:t('error.company_too_poor'), 'error')
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
exports['qb-banking']:RemoveMoney(Player.PlayerData.job.name, payment, 'Employee Paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
exports['qb-banking']:RemoveMoney(Player.PlayerData.job.name, payment,
'Employee Paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source,
Lang:t('info.received_paycheck', { value = payment }))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source,
Lang:t('info.received_paycheck', { value = payment }))
end
else
Player.Functions.AddMoney('bank', payment, 'paycheck')
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source,
Lang:t('info.received_paycheck', { value = payment }))
end
end
end
@@ -438,20 +444,12 @@ function QBCore.Functions.TriggerClientCallback(name, source, ...)
local cb = nil
local args = { ... }
if type(args[1]) == "function" then
if QBCore.Shared.IsFunction(args[1]) then
cb = args[1]
table.remove(args, 1)
elseif type(args[1]) == "table" then
local _, err = pcall(function()
args[1]["__cfx_functionReferenc"] = args[1]["__cfx_functionReferenc"]
end)
if err and string.find(err, "Cannot index a funcref") then
cb = args[1]
table.remove(args, 1)
end
end
QBCore.ClientCallbacks[name] = {
callback = cb,
promise = promise.new()
@@ -651,7 +649,12 @@ function QBCore.Functions.IsPlayerBanned(source)
if not result then return false end
if os.time() < result.expire then
local timeTable = os.date('*t', tonumber(result.expire))
return true, 'You have been banned from the server:\n' .. result.reason .. '\nYour ban expires ' .. timeTable.day .. '/' .. timeTable.month .. '/' .. timeTable.year .. ' ' .. timeTable.hour .. ':' .. timeTable.min .. '\n'
return true,
'You have been banned from the server:\n' ..
result.reason ..
'\nYour ban expires ' ..
timeTable.day ..
'/' .. timeTable.month .. '/' .. timeTable.year .. ' ' .. timeTable.hour .. ':' .. timeTable.min .. '\n'
else
MySQL.query('DELETE FROM bans WHERE id = ?', { result.id })
end
@@ -732,7 +735,8 @@ function QBCore.Functions.PrepForSQL(source, data, pattern)
local player = QBCore.Functions.GetPlayer(src)
local result = string.match(data, pattern)
if not result or string.len(result) ~= string.len(data) then
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'SQL Exploit Attempted', 'red', string.format('%s attempted to exploit SQL!', player.PlayerData.license))
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'SQL Exploit Attempted', 'red',
string.format('%s attempted to exploit SQL!', player.PlayerData.license))
return false
end
return true