mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 09:18:53 +00:00
Added Paycheck Logging
Added a config variable to config.lua to enable/disable paycheck logging to Discord, added config option to config.logs.lua for Discord webhook and added function into paycheck.lua to send data to webhook containing paycheck information.
This commit is contained in:
@@ -4,7 +4,8 @@ Config.DiscordLogs = {
|
||||
test = '',
|
||||
Chat = '',
|
||||
UserActions = '',
|
||||
Resources = ''
|
||||
Resources = '',
|
||||
Paycheck = ''
|
||||
},
|
||||
|
||||
Colors = { -- https://www.spycolor.com/
|
||||
|
||||
@@ -21,6 +21,7 @@ Config.StartingAccountMoney = {bank = 50000}
|
||||
Config.DefaultSpawn = {x = -269.4, y = -955.3, z = 31.2, heading = 205.8}
|
||||
|
||||
Config.EnablePaycheck = true -- enable paycheck
|
||||
Config.LogPaycheck = false -- Logs paychecks to a nominated Discord channel via webhook (default is false)
|
||||
Config.EnableSocietyPayouts = false -- pay from the society account that the player is employed at? Requirement: esx_society
|
||||
Config.MaxWeight = 24 -- the max inventory weight without backpack
|
||||
Config.PaycheckInterval = 7 * 60000 -- how often to recieve pay checks in milliseconds
|
||||
|
||||
@@ -4,6 +4,7 @@ function StartPayCheck()
|
||||
Wait(Config.PaycheckInterval)
|
||||
|
||||
for player, xPlayer in pairs(ESX.Players) do
|
||||
local jobLabel = xPlayer.job.label
|
||||
local job = xPlayer.job.grade_name
|
||||
local salary = xPlayer.job.grade_salary
|
||||
|
||||
@@ -12,6 +13,13 @@ function StartPayCheck()
|
||||
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}
|
||||
})
|
||||
end
|
||||
elseif Config.EnableSocietyPayouts then -- possibly a society
|
||||
TriggerEvent('esx_society:getSociety', xPlayer.job.name, function(society)
|
||||
if society ~= nil then -- verified society
|
||||
@@ -19,6 +27,13 @@ function StartPayCheck()
|
||||
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}
|
||||
})
|
||||
end
|
||||
|
||||
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'),
|
||||
TranslateCap('received_salary', salary), 'CHAR_BANK_MAZE', 9)
|
||||
@@ -28,12 +43,26 @@ function StartPayCheck()
|
||||
end)
|
||||
else -- not a society
|
||||
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}
|
||||
})
|
||||
end
|
||||
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary),
|
||||
'CHAR_BANK_MAZE', 9)
|
||||
end
|
||||
end)
|
||||
else -- generic job
|
||||
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}
|
||||
})
|
||||
end
|
||||
TriggerClientEvent('esx:showAdvancedNotification', player, TranslateCap('bank'), TranslateCap('received_paycheck'), TranslateCap('received_salary', salary),
|
||||
'CHAR_BANK_MAZE', 9)
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user