mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-29 13:01:31 +00:00
feat(es_extended): Added "Duty" system
feat(es_extended): Added "Duty" system
This commit is contained in:
@@ -20,5 +20,5 @@ Config.EnablePVP = true -- Allow Player to player combat
|
||||
|
||||
Config.Multichar = true -- Enable support for esx_multicharacter
|
||||
Config.Identity = true -- Select a characters identity data before they have loaded in (this happens by default with multichar)
|
||||
|
||||
Config.DistanceGive = 4.0 -- Max distance when giving items, weapons etc.
|
||||
Config.OnDuty = true -- Default state of the on duty system
|
||||
|
||||
@@ -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.',
|
||||
}
|
||||
|
||||
@@ -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.',
|
||||
}
|
||||
|
||||
@@ -356,6 +356,11 @@ function CreateExtendedPlayer(playerId, identifier, group, accounts, inventory,
|
||||
end
|
||||
end
|
||||
|
||||
function self.setDuty(bool)
|
||||
self.job.onDuty = bool
|
||||
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 = Config.OnDuty
|
||||
|
||||
if gradeObject.skin_male then
|
||||
self.job.skin_male = json.decode(gradeObject.skin_male)
|
||||
|
||||
@@ -93,6 +93,7 @@ MySQL.ready(function()
|
||||
grade = 0,
|
||||
label = 'Unemployed',
|
||||
salary = 200,
|
||||
onDuty = false,
|
||||
skin_male = {},
|
||||
skin_female = {}
|
||||
}
|
||||
|
||||
@@ -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 = Config.OnDuty
|
||||
|
||||
userData.job.skin_male = {}
|
||||
userData.job.skin_female = {}
|
||||
@@ -613,3 +614,18 @@ AddEventHandler('txAdmin:events:scheduledRestart', function(eventData)
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNetEvent('esx:setDuty')
|
||||
AddEventHandler('esx:setDuty', function(bool)
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
if xPlayer.job.onDuty == bool then return end
|
||||
|
||||
if bool then
|
||||
xPlayer.setDuty(true)
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('started_duty'))
|
||||
else
|
||||
xPlayer.setDuty(false)
|
||||
xPlayer.triggerEvent('esx:showNotification', _U('stopped_duty'))
|
||||
end
|
||||
TriggerClientEvent('esx:setJob', xPlayer.source, xPlayer.job)
|
||||
end)
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user