New OnDuty System for jobs.

- Added a setDuty event.
- Added a job.onduty data.
- Default onduty is false at connection and creation of the user, job change.
- Added a esx:toggleDuty event to change the state of the duty.
This commit is contained in:
ZF
2022-03-18 19:15:48 -04:00
parent 9827a02d9c
commit 36ac7ef2d1
15 changed files with 68 additions and 2 deletions
+4
View File
@@ -222,4 +222,8 @@ Locales['br'] = {
['tint_lspd'] = 'blue skin',
['tint_orange'] = 'orange skin',
['tint_platinum'] = 'platinum skin',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['cs'] = {
['tint_lspd'] = 'modry skin',
['tint_orange'] = 'oranzovy skin',
['tint_platinum'] = 'platinovy skin',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['de'] = {
['tint_lspd'] = 'blau',
['tint_orange'] = 'orange',
['tint_platinum'] = 'platin',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -343,4 +343,8 @@ Locales['en'] = {
['tint_lspd'] = 'blue skin',
['tint_orange'] = 'orange skin',
['tint_platinum'] = 'platinum skin',
-- Duty related
['stopped_duty'] = 'You\'ve stopped your duty.',
['started_duty'] = 'You\'ve started your duty.',
}
+4
View File
@@ -343,4 +343,8 @@ Locales['es'] = {
['tint_lspd'] = 'Skin Azul',
['tint_orange'] = 'Skin Naranja',
['tint_platinum'] = 'Skin Plata',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['fi'] = {
['tint_lspd'] = 'blue skin',
['tint_orange'] = 'orange skin',
['tint_platinum'] = 'platinum skin',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['fr'] = {
['tint_lspd'] = 'skin bleu',
['tint_orange'] = 'skin orange',
['tint_platinum'] = 'skin platine',
-- Duty related
['stopped_duty'] = 'Vous êtes maintenant hors-service.',
['started_duty'] = 'Vous êtes maintenant en-service.',
}
+4
View File
@@ -221,4 +221,8 @@ Locales['pl'] = {
['tint_lspd'] = 'niebieski skin',
['tint_orange'] = 'pomarańczowy skin',
['tint_platinum'] = 'platynowy skin',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['sc'] = {
['tint_lspd'] = '洛圣都警局色调',
['tint_orange'] = '橙色调',
['tint_platinum'] = '铂金色调',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['sv'] = {
['tint_lspd'] = 'blåskinn',
['tint_orange'] = 'orangeskinn',
['tint_platinum'] = 'platinaskinn',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
+4
View File
@@ -222,4 +222,8 @@ Locales['tc'] = {
['tint_lspd'] = '洛聖都警察局色調',
['tint_orange'] = '橘色調',
['tint_platinum'] = '柏金色調',
-- Duty related
['stopped_duty'] = 'NEED TRANSLATION',
['started_duty'] = 'NEED TRANSLATION',
}
@@ -356,6 +356,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
end
end
function self.setDuty(onDuty)
self.job.onduty = onDuty
self.triggerEvent('esx:setJob', self.job)
end
function self.setJob(job, grade)
grade = tostring(grade)
local lastJob = json.decode(json.encode(self.job))
@@ -371,6 +376,7 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
self.job.grade_name = gradeObject.name
self.job.grade_label = gradeObject.label
self.job.grade_salary = gradeObject.salary
self.job.onduty = false
if gradeObject.skin_male then
self.job.skin_male = json.decode(gradeObject.skin_male)
+1
View File
@@ -93,6 +93,7 @@ MySQL.ready(function()
grade = 0,
label = 'Unemployed',
salary = 200,
onduty = false,
skin_male = {},
skin_female = {}
}
+14
View File
@@ -156,6 +156,7 @@ function loadESXPlayer(identifier, playerId, isNew)
userData.job.grade_name = gradeObject.name
userData.job.grade_label = gradeObject.label
userData.job.grade_salary = gradeObject.salary
userData.job.onduty = false
userData.job.skin_male = {}
userData.job.skin_female = {}
@@ -600,3 +601,16 @@ AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
end)
end
end)
RegisterNetEvent('esx:toggleDuty')
AddEventHandler('esx:toggleDuty', function()
local xPlayer = ESX.GetPlayerFromId(source)
if xPlayer.job.onduty then
xPlayer.setDuty(false)
xPlayer.triggerEvent('esx:showNotification', _U('stopped_duty'))
else
xPlayer.setDuty(true)
xPlayer.triggerEvent('esx:showNotification', _U('started_duty'))
end
TriggerClientEvent('esx:setJob', source, xPlayer.job)
end)
+3 -2
View File
@@ -5,13 +5,14 @@ function StartPayCheck()
local xPlayers = ESX.GetExtendedPlayers()
for _, xPlayer in pairs(xPlayers) do
local job = xPlayer.job.grade_name
local onduty = xPlayer.job.onduty
local salary = xPlayer.job.grade_salary
if salary > 0 then
if job == 'unemployed' then -- unemployed
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_help', salary), 'CHAR_BANK_MAZE', 9)
elseif Config.EnableSocietyPayouts then -- possibly a society
elseif Config.EnableSocietyPayouts and onduty 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)
@@ -29,7 +30,7 @@ function StartPayCheck()
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_salary', salary), 'CHAR_BANK_MAZE', 9)
end
end)
else -- generic job
elseif onduty then -- generic job
xPlayer.addAccountMoney('bank', salary)
TriggerClientEvent('esx:showAdvancedNotification', xPlayer.source, _U('bank'), _U('received_paycheck'), _U('received_salary', salary), 'CHAR_BANK_MAZE', 9)
end