Improved paycheck system, added advanced notifications, see desc

- Improved paycheck system
    - we now take society money if there is any, or else the employees wont get a salary at all
    - now using ESX.ShowAdvancedNotifications
This commit is contained in:
ElPumpo
2018-05-11 13:57:35 +02:00
parent 987a40bf0d
commit 66e7eceddf
14 changed files with 137 additions and 395 deletions
+12
View File
@@ -65,6 +65,13 @@ ESX.ShowNotification = function(msg)
DrawNotification(0,1)
end
ESX.ShowAdvancedNotification = function(title, subject, msg, icon, iconType)
SetNotificationTextEntry('STRING')
AddTextComponentString(msg)
SetNotificationMessage(icon, icon, false, iconType, title, subject)
DrawNotification(false, false)
end
ESX.TriggerServerCallback = function(name, cb, ...)
ESX.ServerCallbacks[ESX.CurrentRequestId] = cb
@@ -1394,6 +1401,11 @@ AddEventHandler('esx:showNotification', function(msg)
ESX.ShowNotification(msg)
end)
RegisterNetEvent('esx:showAdvancedNotification')
AddEventHandler('esx:showAdvancedNotification', function(title, subject, msg, icon, iconType)
ESX.ShowAdvancedNotification(title, subject, msg, icon, iconType)
end)
-- SetTimeout
Citizen.CreateThread(function()
while true do
+36 -41
View File
@@ -1,69 +1,64 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
;
CREATE TABLE `items` (
`name` varchar(50) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
PRIMARY KEY (`name`)
);
CREATE TABLE `job_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL DEFAULT '{}',
`skin_female` longtext NOT NULL DEFAULT '{}',
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL,
`skin_female` longtext NOT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`)
);
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'rsa','RSA',200,'{}','{}');
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'unemployed','Unemployed',200,'{}','{}');
CREATE TABLE `jobs` (
`name` varchar(50) NOT NULL,
`label` varchar(255) DEFAULT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`name`)
);
INSERT INTO `jobs` VALUES (1,'unemployed','Chômeur');
INSERT INTO `jobs` VALUES ('unemployed','Unemployed');
CREATE TABLE `user_accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
PRIMARY KEY (`id`)
);
CREATE TABLE `user_inventory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
PRIMARY KEY (`id`)
);
+8 -5
View File
@@ -24,11 +24,14 @@ Locales['br'] = {
['imp_invalid_amount'] = 'ação impossível, valor inválido',
['delete_five_min'] = '~r~excluir~s~ em 5 minutos',
['threw'] = 'você ~r~jogou~s~',
['rec_salary'] = 'você recebeu seu salário: ',
['rec_help'] = 'você recebeu seu cheque de bem-estar: ',
['company_paid'] = 'Cheque de pagamento da empresa recebido',
['company_nomoney'] = 'Sua empresa está falida!',
['state_paid'] = 'Você recebeu um cheque de estado',
-- Salary related
['recived_salary'] = 'você recebeu seu salário: ',
['recived_help'] = 'você recebeu seu cheque de bem-estar: ',
['company_nomoney'] = 'Sua empresa está falida!', -- incorrect translation
['recived_money'] = 'recived money',
['bank'] = 'bank',
['act_imp'] = 'ação impossível',
['in_vehicle'] = 'Você não pode dar nada para alguém no veículo',
['cannot_pickup_room'] = 'you do not have enough space in your inventory to pick up ~y~%s~s~!',
+13 -7
View File
@@ -1,4 +1,10 @@
Locales['de'] = {
['inventory'] = 'Inventar',
['use'] = 'benutzen',
['give'] = 'geben',
['remove'] = 'entfernen',
['return'] = 'zurück',
['amount'] = 'Betrag',
['amountammo'] = 'anzahl der Munition',
['noammo'] = 'du hast keine Munition!',
['threw_weapon'] = 'you ~r~threw~s~ ~y~1x~s~ ~b~%s~s~ with ~o~%sx~s~ bullets!',
@@ -7,12 +13,6 @@ Locales['de'] = {
['gave_ammo'] = 'you gave ~o~%sx~s~ bullets to ~y~%s~s~.',
['recived_ammo'] = 'you recived ~o~%sx~s~ bullets from ~b~%s~s~.',
['giveammo'] = 'Munition geben',
['inventory'] = 'Inventar',
['use'] = 'benutzen',
['give'] = 'geben',
['remove'] = 'entfernen',
['return'] = 'zurück',
['amount'] = 'Betrag',
['amount_invalid'] = 'ungültiger Betrag',
['players_nearby'] = 'keine Spieler in der Nähe',
['ex_inv_lim'] = 'Aktion nicht möglich, inventarlimit überschritten für ~b~',
@@ -24,7 +24,13 @@ Locales['de'] = {
['imp_invalid_amount'] = 'Aktion nicht möglich, ungültiger Betrag',
['delete_five_min'] = '~r~löschen~s~ in 5 Minuten',
['threw'] = 'du ~r~wirfst weg~s~',
['rec_salary'] = 'du hast dein Gehalt erhalten: ',
-- Salary related
['recived_salary'] = 'du hast dein Gehalt erhalten: ~g~$%s~s~',
['recived_help'] = 'you recieved your welfare check: ~g~$%s~s~',
['company_nomoney'] = 'the company you\'re employeed at is too poor to pay out your salary.',
['recived_money'] = 'recived money',
['bank'] = 'bank',
['act_imp'] = 'Aktion nicht möglich',
-- Commands
['setjob'] = 'assign a job to a user',
+7 -5
View File
@@ -24,11 +24,13 @@ Locales['en'] = {
['imp_invalid_amount'] = 'action impossible, invalid amount',
['delete_five_min'] = 'the item will be ~r~thrown~s~ in 5 minutes',
['threw'] = 'you ~r~threw~s~',
['rec_salary'] = 'you received your salary: ',
['rec_help'] = 'you recieved your welfare check: ',
['company_paid'] = 'company paycheck received',
['company_nomoney'] = 'your company is broke!',
['state_paid'] = 'You received a state check',
-- Salary related
['recived_salary'] = 'you received your salary: ~g~$%s~s~',
['recived_help'] = 'you recieved your welfare check: ~g~$%s~s~',
['company_nomoney'] = 'the company you\'re employeed at is too poor to pay out your salary.',
['recived_money'] = 'recived money',
['bank'] = 'bank',
['act_imp'] = 'action impossible',
['in_vehicle'] = 'you can\'t give anything to someone in a vehicle',
['cannot_pickup_room'] = 'you do not have enough space in your inventory to pick up ~y~%s~s~!',
+7 -5
View File
@@ -24,11 +24,13 @@ Locales['fr'] = {
['imp_invalid_amount'] = 'action impossible, ~r~montant invalide',
['delete_five_min'] = '~r~suppression~s~ dans 5 minutes',
['threw'] = 'vous avez ~r~jeté~s~',
['rec_salary'] = 'vous avez reçu votre salaire : ',
['rec_help'] = 'vous avez reçu une aide de l\'état : ',
['company_paid'] = 'Votre entreprise vous a payé ',
['company_nomoney'] = 'Votre entreprise n\'a plus d\'argent pour vous payer !',
['state_paid'] = 'L\'état vous a payé ',
-- Salary related
['recived_salary'] = 'vous avez reçu votre salaire: ~g~$%s~s~',
['recived_help'] = 'vous avez reçu une aide de l\'état: ~g~$%s~s~',
['company_nomoney'] = 'votre entreprise n\'a plus d\'argent pour vous payer!', -- fix translation
['recived_money'] = 'recived money',
['bank'] = 'bank',
['act_imp'] = 'action impossible',
['in_vehicle'] = 'Vous ne pouvez rien donner à quelqu\'un dans un véhicule',
['cannot_pickup_room'] = 'vous n\'avez plus de place pour ~y~%s~s~!',
+7 -5
View File
@@ -24,11 +24,13 @@ Locales['sv'] = {
['imp_invalid_amount'] = 'åtgärd omöjlig, ogiltig belopp',
['delete_five_min'] = 'objektet kommer att ~r~tas bort~s~ om 5 minuter!',
['threw'] = 'du ~r~kastade~s~',
['rec_salary'] = 'du fick din lön: ',
['rec_help'] = 'du fick din välfärdskontroll: ',
['company_paid'] = 'Företags lön mottaget',
['company_nomoney'] = 'Ditt företag är för fattigt!!',
['state_paid'] = 'Du fick en statlig check',
-- Salary related
['recived_salary'] = 'du har mottagit din lön på ~g~$%s~s~',
['recived_help'] = 'du har mottagit bidrag på ~g~$%s~s~',
['company_nomoney'] = 'företaget du är anställt hos har inte råd att betala ut din lön.',
['recived_money'] = 'mottagit pengar',
['bank'] = 'bank',
['act_imp'] = 'åtgärd omöjlig',
['in_vehicle'] = 'du kan inte ge saker till en som sitter i ett fordon!',
['cannot_pickup_room'] = 'du har inte plats för att plocka upp ~y~%s~s~!',
-69
View File
@@ -1,69 +0,0 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
;
CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
);
CREATE TABLE `job_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL,
`skin_female` longtext NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'rsa','Desempregado',200,'{}','{}');
CREATE TABLE `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `jobs` VALUES (1,'unemployed','Desempregado');
CREATE TABLE `user_accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE TABLE `user_inventory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
-69
View File
@@ -1,69 +0,0 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
;
CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
);
CREATE TABLE `job_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL,
`skin_female` longtext NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'rsa','Arbeitslos',200,'{}','{}');
CREATE TABLE `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `jobs` VALUES (1,'unemployed','Suchend');
CREATE TABLE `user_accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE TABLE `user_inventory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
-69
View File
@@ -1,69 +0,0 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
;
CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
);
CREATE TABLE `job_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL,
`skin_female` longtext NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'rsa','Welfare',200,'{}','{}');
CREATE TABLE `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `jobs` VALUES (1,'unemployed','Unemployed');
CREATE TABLE `user_accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE TABLE `user_inventory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
-69
View File
@@ -1,69 +0,0 @@
USE `essentialmode`;
ALTER TABLE `users`
ADD COLUMN `name` VARCHAR(255) NULL DEFAULT '' AFTER `money`,
ADD COLUMN `skin` LONGTEXT NULL AFTER `name`,
ADD COLUMN `job` varchar(255) NULL DEFAULT 'unemployed' AFTER `skin`,
ADD COLUMN `job_grade` INT NULL DEFAULT 0 AFTER `job`,
ADD COLUMN `loadout` LONGTEXT NULL AFTER `job_grade`,
ADD COLUMN `position` VARCHAR(255) NULL AFTER `loadout`
;
CREATE TABLE `items` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`limit` int(11) NOT NULL DEFAULT '-1',
`rare` int(11) NOT NULL DEFAULT '0',
`can_remove` int(11) NOT NULL DEFAULT '1',
PRIMARY KEY (`id`)
);
CREATE TABLE `job_grades` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`job_name` varchar(255) DEFAULT NULL,
`grade` int(11) NOT NULL,
`name` varchar(255) NOT NULL,
`label` varchar(255) NOT NULL,
`salary` int(11) NOT NULL,
`skin_male` longtext NOT NULL,
`skin_female` longtext NOT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `job_grades` VALUES (1,'unemployed',0,'rsa','A-Kassa',200,'{}','{}');
CREATE TABLE `jobs` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL,
`label` varchar(255) DEFAULT NULL,
PRIMARY KEY (`id`)
);
INSERT INTO `jobs` VALUES (1,'unemployed','Arbetslös');
CREATE TABLE `user_accounts` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`name` varchar(255) NOT NULL,
`money` double NOT NULL DEFAULT '0',
PRIMARY KEY (`id`)
);
CREATE TABLE `user_inventory` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`identifier` varchar(255) NOT NULL,
`item` varchar(255) NOT NULL,
`count` int(11) NOT NULL,
PRIMARY KEY (`id`)
);
+10 -2
View File
@@ -17,8 +17,16 @@ end, function(source, args, user)
end, {help = "Teleport to coordinates", params = {{name = "x", help = "X coords"}, {name = "y", help = "Y coords"}, {name = "z", help = "Z coords"}}})
TriggerEvent('es:addGroupCommand', 'setjob', 'jobmaster', function(source, args, user)
local xPlayer = ESX.GetPlayerFromId(args[1])
xPlayer.setJob(args[2], tonumber(args[3]))
if tonumber(args[1]) and args[2] and tonumber(args[3]) then
local xPlayer = ESX.GetPlayerFromId(args[1])
if xPlayer ~= nil then
xPlayer.setJob(args[2], args[3])
else
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Player not online.")
end
else
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Invalid usage.")
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, "SYSTEM", {255, 0, 0}, "Insufficient Permissions.")
end, {help = _U('setjob'), params = {{name = "id", help = _U('id_param')}, {name = "job", help = _U('setjob_param2')}, {name = "grade_id", help = _U('setjob_param3')}}})
+37 -19
View File
@@ -1,29 +1,47 @@
ESX.StartPayCheck = function()
function payCheck()
function payCheck()
local xPlayers = ESX.GetPlayers()
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
for i=1, #xPlayers, 1 do
if salary > 0 then
if job == 'unemployed' then -- unemployed
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_help', salary), 'CHAR_BANK_MAZE', 9)
elseif job == 'employee' then -- generic job, not a society
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
else -- 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('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
else
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), '', _U('company_nomoney'), 'CHAR_BANK_MAZE', 1)
end
end)
else -- not a society, use 'employee' as grade name!
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('recived_money'), _U('recived_salary', salary), 'CHAR_BANK_MAZE', 9)
end
end)
end
end
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
end
if xPlayer.job.grade_salary > 0 then
xPlayer.addMoney(xPlayer.job.grade_salary)
SetTimeout(Config.PaycheckInterval, payCheck)
if xPlayer.job.grade_name == 'interim' then
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rec_help') .. '~g~$' .. xPlayer.job.grade_salary)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('rec_salary') .. '~g~$' .. xPlayer.job.grade_salary)
end
end
end
end
SetTimeout(Config.PaycheckInterval, payCheck)
end
SetTimeout(Config.PaycheckInterval, payCheck)
SetTimeout(Config.PaycheckInterval, payCheck)
end
-30
View File
@@ -1,30 +0,0 @@
ESX.StartPayCheck = function ()
function payCheck ()
local xPlayers = ESX.GetPlayers()
for i=1, #xPlayers, 1 do
local xPlayer = ESX.GetPlayerFromId(xPlayers[i])
if xPlayer.job.grade_name == 'interim' or xPlayer.job.grade_name == 'rsa' or xPlayer.job.grade_name == 'employee' then -- only if the player is employeed in a company
if xPlayer.job.grade_salary > 0 then
xPlayer.addAccountMoney('bank', xPlayer.job.grade_salary)
TriggerClientEvent('esx:showNotification', xPlayer.source, ('L\'état vous a payé ') .. '~g~$' .. xPlayer.job.grade_salary)
end
else -- Else take money from society
TriggerEvent('esx_society:getSociety', xPlayer.job.name, function (society)
TriggerEvent('esx_addonaccount:getSharedAccount', society.account, function (account)
if account.money >= xPlayer.job.grade_salary then
xPlayer.addAccountMoney('bank',xPlayer.job.grade_salary)
account.removeMoney(xPlayer.job.grade_salary)
TriggerClientEvent('esx:showNotification', xPlayer.source, ('Votre entreprise vous a payé ') .. '~g~$' .. xPlayer.job.grade_salary)
else
TriggerClientEvent('esx:showNotification', xPlayer.source, 'Votre entreprise n\'a plus d\'argent pour vous payer !')
end
end)
end)
end
end
SetTimeout(Config.PaycheckInterval, payCheck)
end
SetTimeout(Config.PaycheckInterval, payCheck)
end