Get/SetPlayerDuty
This commit is contained in:
1 parent
329d3328d8
commit
5d3a9d1950
3 files changed
+67
-24
No files matched your search
@@ -172,12 +172,41 @@ Framework.GetPlayerPhone = function(src)
|
||||
return xPlayer.get("phone_number")
|
||||
end
|
||||
|
||||
-- Framework.GetPlayerJob(src)
|
||||
-- Returns the job name, label, grade name, and grade level of the player.
|
||||
|
||||
---Returns the job name, label, grade name, and grade level of the player.
|
||||
---@param src number
|
||||
---@return string | nil
|
||||
---@return string | nil
|
||||
---@return string | nil
|
||||
---@return string | nil
|
||||
Framework.GetPlayerJob = function(src)
|
||||
local xPlayer = ESX.GetPlayerFromId(src)
|
||||
if not xPlayer then return end
|
||||
return xPlayer.getJob().name, xPlayer.getJob().label, xPlayer.getJob().grade_label, xPlayer.getJob().grade
|
||||
local job = xPlayer.getJob()
|
||||
return job.name, job.label, job.grade_label, job.grade
|
||||
end
|
||||
|
||||
---Returns the players duty status.
|
||||
---@param src number
|
||||
---@return boolean
|
||||
Framework.GetPlayerDuty = function(src)
|
||||
local xPlayer = ESX.GetPlayerFromId(src)
|
||||
if not xPlayer then return false end
|
||||
local job = xPlayer.getJob()
|
||||
if not job.onDuty then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
---Sets the players duty status.
|
||||
---@param src number
|
||||
---@param dutystatus boolean
|
||||
---@return boolean
|
||||
Framework.SetPlayerDuty = function(src, dutystatus)
|
||||
local xPlayer = ESX.GetPlayerFromId(src)
|
||||
if not xPlayer then return false end
|
||||
local job = xPlayer.getJob()
|
||||
if not job.onDuty then return false end
|
||||
return xPlayer.setJob(job.name, job.grade, dutystatus)
|
||||
end
|
||||
|
||||
-- Framework.GetPlayersByJob(jobname)
|
||||
@@ -203,14 +232,6 @@ Framework.SetPlayerJob = function(src, name, grade)
|
||||
return xPlayer.setJob(name, grade, true)
|
||||
end
|
||||
|
||||
Framework.ToggleDuty = function(src, status)
|
||||
local xPlayer = ESX.GetPlayerFromId(src)
|
||||
if not xPlayer then return end
|
||||
local name = xPlayer.getJob().name
|
||||
local grade = xPlayer.getJob().grade
|
||||
xPlayer.setJob(name, grade, status)
|
||||
end
|
||||
|
||||
-- Framework.AddAccountBalance(src, _type, amount)
|
||||
-- Adds the specified amount to the player's account balance of the specified type.
|
||||
Framework.AddAccountBalance = function(src, _type, amount)
|
||||
|
||||
@@ -308,6 +308,28 @@ Framework.GetPlayerJob = function(src)
|
||||
return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level
|
||||
end
|
||||
|
||||
---Returns the players duty status.
|
||||
---@param src number
|
||||
---@return boolean | nil
|
||||
Framework.GetPlayerDuty = function(src)
|
||||
local player = QBCore.Functions.GetPlayer(src)
|
||||
if not player then return end
|
||||
local playerData = player.PlayerData
|
||||
if not playerData.job.onduty then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
---This will toggle a players duty status
|
||||
---@param src number
|
||||
---@param status boolean
|
||||
---@return nil
|
||||
Framework.SetPlayerDuty = function(src, status)
|
||||
local player = QBCore.Functions.GetPlayer(src)
|
||||
if not player then return end
|
||||
player.Functions.SetJobDuty(status)
|
||||
TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty)
|
||||
end
|
||||
|
||||
-- Sets the player's job to the specified name and grade.
|
||||
---@param src number
|
||||
---@param name string
|
||||
@@ -319,18 +341,6 @@ Framework.SetPlayerJob = function(src, name, grade)
|
||||
return player.Functions.SetJob(name, grade)
|
||||
end
|
||||
|
||||
---This will toggle a players duty status
|
||||
---@param src number
|
||||
---@param status boolean
|
||||
---@return nil
|
||||
Framework.ToggleDuty = function(src, status)
|
||||
local player = QBCore.Functions.GetPlayer(src)
|
||||
if not player then return end
|
||||
player.Functions.SetJobDuty(status)
|
||||
TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty)
|
||||
end
|
||||
|
||||
|
||||
---This will add money based on the type of account (money/bank)
|
||||
---@param src number
|
||||
---@param _type string
|
||||
|
||||
@@ -287,11 +287,23 @@ end
|
||||
---This will toggle the duty status of the player.
|
||||
---@param src number
|
||||
---@param status boolean
|
||||
Framework.ToggleDuty = function(src, status)
|
||||
Framework.SetPlayerDuty = function(src, status)
|
||||
local player = QBox:GetPlayer(src)
|
||||
if not player then return end
|
||||
local playerData = player.PlayerData
|
||||
QBox:SetJobDuty(playerData.citizenid, status)
|
||||
TriggerEvent('QBCore:Server:SetDuty', src, player.PlayerData.job.onduty)
|
||||
end
|
||||
|
||||
---Returns the players duty status.
|
||||
---@param src number
|
||||
---@return boolean | nil
|
||||
Framework.GetPlayerDuty = function(src)
|
||||
local player = QBox:GetPlayer(src)
|
||||
if not player then return end
|
||||
local playerData = player.PlayerData
|
||||
if not playerData.job.onduty then return false end
|
||||
return true
|
||||
end
|
||||
|
||||
---Adds the specified amount to the player's account balance of the specified type.
|
||||
|
||||
Reference in new issue
Block a user