mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 01:08:54 +00:00
feat(paycheck): add event
This commit is contained in:
@@ -9,29 +9,30 @@ function StartPayCheck()
|
||||
local salary = (job == "unemployed" or onDuty) and xPlayer.job.grade_salary or ESX.Math.Round(xPlayer.job.grade_salary * Config.OffDutyPaycheckMultiplier)
|
||||
|
||||
if xPlayer.paycheckEnabled then
|
||||
TriggerEvent("esx:paycheckReceived", xPlayer.source, salary, job, jobLabel, onDuty)
|
||||
if salary > 0 then
|
||||
if job == "unemployed" then -- unemployed
|
||||
xPlayer.addAccountMoney("bank", salary, "Welfare Check")
|
||||
TriggerClientEvent("esx:showAdvancedNotification", player, TranslateCap("bank"), TranslateCap("received_paycheck"), TranslateCap("received_help", salary), "CHAR_BANK_MAZE", 9)
|
||||
if Config.LogPaycheck then
|
||||
ESX.DiscordLogFields("Paycheck", "Paycheck - Unemployment Benefits", "green", {
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
})
|
||||
end
|
||||
elseif Config.EnableSocietyPayouts then -- possibly a society
|
||||
elseif Config.EnableSocietyPayouts then -- possibly a society
|
||||
TriggerEvent("esx_society:getSociety", xPlayer.job.name, function(society)
|
||||
if society ~= nil then -- verified 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, "Paycheck")
|
||||
account.removeMoney(salary)
|
||||
if Config.LogPaycheck then
|
||||
ESX.DiscordLogFields("Paycheck", "Paycheck - " .. jobLabel, "green", {
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
})
|
||||
end
|
||||
|
||||
@@ -44,9 +45,9 @@ function StartPayCheck()
|
||||
xPlayer.addAccountMoney("bank", salary, "Paycheck")
|
||||
if Config.LogPaycheck then
|
||||
ESX.DiscordLogFields("Paycheck", "Paycheck - " .. jobLabel, "green", {
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
})
|
||||
end
|
||||
TriggerClientEvent("esx:showAdvancedNotification", player, TranslateCap("bank"), TranslateCap("received_paycheck"), TranslateCap("received_salary", salary), "CHAR_BANK_MAZE", 9)
|
||||
@@ -56,9 +57,9 @@ function StartPayCheck()
|
||||
xPlayer.addAccountMoney("bank", salary, "Paycheck")
|
||||
if Config.LogPaycheck then
|
||||
ESX.DiscordLogFields("Paycheck", "Paycheck - Generic", "green", {
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
{ name = "Player", value = xPlayer.name, inline = true },
|
||||
{ name = "ID", value = xPlayer.source, inline = true },
|
||||
{ name = "Amount", value = salary, inline = true },
|
||||
})
|
||||
end
|
||||
TriggerClientEvent("esx:showAdvancedNotification", player, TranslateCap("bank"), TranslateCap("received_paycheck"), TranslateCap("received_salary", salary), "CHAR_BANK_MAZE", 9)
|
||||
|
||||
Reference in New Issue
Block a user