ESX.StartPayCheck = function()
function payCheck()
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
local job = xPlayer.job.grade_name
local salary = xPlayer.job.grade_salary
if salary > 0 then
local result = MySQL.Sync.fetchAll("SELECT * FROM owned_vehicles WHERE owned_vehicles.owner=@owner", {
['@owner'] = xPlayer.identifier
})
local result2 = MySQL.Sync.fetchAll("SELECT * FROM lsrp_motels WHERE lsrp_motels.ident=@ident", {
['@ident'] = xPlayer.identifier
})
if result2[1] ~= nil then
if result[1] ~= nil then
local kesinti = math.floor(salary - 100)
if kesinti < 0 then
xPlayer.addAccountMoney('bank', 0)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Araç faturası ve Motel kirası kesintisi yapıldı, Maaşın yatırıldı: $0'},4000)
else
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Araç faturası ve Motel kirası kesintisi yapıldı, Maaşın yatırıldı: $' .. kesinti},4000)
xPlayer.addAccountMoney('bank', kesinti)
end
else
local kesinti = math.floor(salary - 50)
if kesinti < 0 then
xPlayer.addAccountMoney('bank', 0)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Motel kirası kesintisi yapıldı, Maaşın yatırıldı: $0'},4000)
else
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Motel kirası kesintisi yapıldı, Maaşın yatırıldı: $' .. kesinti},4000)
xPlayer.addAccountMoney('bank', kesinti)
end
end
else
if result[1] ~= nil then
local kesinti = math.floor(salary - 50)
if kesinti < 0 then
xPlayer.addAccountMoney('bank', 0)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Araç faturası kesintisi yapıldı, Maaşın yatırıldı: $0'},4000)
else
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = 'Araç faturası kesintisi yapıldı, Maaşın yatırıldı: $' .. kesinti},4000)
xPlayer.addAccountMoney('bank', kesinti)
end
else
if job == 'unemployed' then -- unemployed
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)},4000)
elseif Config.EnableSocietyPayouts then -- possibly a society
TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
if society ~= nil then -- verified society
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function (account)
if account.money >= salary then -- does the society money to pay its employees?
xPlayer.addAccountMoney('bank', salary)
account.removeMoney(salary)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)},4000)
else
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)},4000)
end
end)
else -- not a society
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)},4000)
end
end)
else -- generic job
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('mythic_notify:client:SendAlert', xPlayer.source, { type = 'inform', text = _U('received_salary', salary)},4000)
end
end
end
end
end
SetTimeout(Config.PaycheckInterval, payCheck)
end
SetTimeout(Config.PaycheckInterval, payCheck)
end