#qbx_management not hiring
1 messages · Page 1 of 1 (latest)
Hey, did ya edit the code?
i did not edit the code.
-- Callback to hire online player as employee of a given group
---@param employee integer Server ID of target employee to be hired
---@param groupType GroupType
lib.callback.register('qbx_management:server:hireEmployee', function(source, employee, groupType)
local player = exports.qbx_core:GetPlayer(source)
local target = exports.qbx_core:GetPlayer(employee)
if not player.PlayerData[groupType].isboss then return end
if not target then
exports.qbx_core:Notify(source, locale('error.not_around'), 'error')
return
end
local groupName = player.PlayerData[groupType].name
local logArea = groupType == 'gang' and 'Gang' or 'Boss'
if groupType == 'job' then
exports.qbx_core:AddPlayerToJob(target.PlayerData.citizenid, groupName, 0)
exports.qbx_core:SetPlayerPrimaryJob(target.PlayerData.citizenid, groupName)
else
exports.qbx_core:AddPlayerToGang(target.PlayerData.citizenid, groupName, 0)
exports.qbx_core:SetPlayerPrimaryGang(target.PlayerData.citizenid, groupName)
end
local playerFullName = player.PlayerData.charinfo.firstname..' '..player.PlayerData.charinfo.lastname
local targetFullName = target.PlayerData.charinfo.firstname..' '..target.PlayerData.charinfo.lastname
local organizationLabel = player.PlayerData[groupType].label
exports.qbx_core:Notify(source, locale('success.hired_into', targetFullName, organizationLabel), 'success')
exports.qbx_core:Notify(target.PlayerData.source, locale('success.hired_to')..organizationLabel, 'success')
logger.log({source = 'qbx_management', event = 'hireEmployee', message = string.format('%s | %s hired %s into %s at grade %s', logArea, playerFullName, targetFullName, organizationLabel, 0), webhook = config.discordWebhook})
end)```
does the logger log that someone got hired?
i didnt set up the logger since we're in dev stage atm 😅
You should set it up.
it does
does the groupName exists?
no thats the job/gang it would assign
thats just ambulance, so yes
What core version are you on and what are your convar values set to for qbx?
@lethal kernel or @compact venture can you check the convar settings in server.cfg? nevermind, did it myself through phone 😂
We use the V1.18.1 release of the core
set qbx:bucketlockdownmode "inactive" # Sets the lockdown mode as relaxed read here: https://docs.fivem.net/natives/?_0xA0F2201F
set qbx:discordlink "discord.tmrw-rp.be" # Sets the servers discord link
set qbx:max_jobs_per_player 1 # Sets the number of jobs per player
set qbx:max_gangs_per_player 1 # Sets the number of gangs per player
set qbx:setjob_replaces "true" # When true, the SetJob function deletes the previous primary job of the player before setting the new one
set qbx:setgang_replaces "true" # When true, the SetGang function deletes the previous primary gang of the player before setting the new one```
The error is probably getting buried unfortunately. Need to update qbx_management not to do so
Alright, is there any alternative to qbx_management?
Many thanks in advance 🙏
Other resources have some issues. I’ll debug and fix this tonight.
Hero ❤️
@lyric grove Could you try with https://github.com/Qbox-project/qbx_management/pull/68
i tested this, getting this error though. Using v1.2.1
Did you modify core or management at all? I don't see how this error is possible.
i only added a function to create a citizenid based of the birthdate in the core.
Could you show the code in qbx_management server/main line 107 and the qbx_core AddPlayerToJob export code you have?
local success, errorResult = exports.qbx_core:AddPlayerToJob(target.PlayerData.citizenid, groupName, 0) -- line 106
assert(success, errorResult.message)```
this is how SSN work in Belgium.
I wanted to have the same format 😅
Last 5 digits are random
---Adds a player to the job or overwrites their grade for a job already held
---@param citizenid string
---@param jobName string
---@param grade integer
---@return boolean success
---@return ErrorResult? errorResult
function AddPlayerToJob(citizenid, jobName, grade)
-- unemployed job is the default, so players cannot be added to it
if jobName == 'unemployed' then
return false, {
code = 'unemployed',
message = 'players cannot be added to the unemployed job'
}
end
local job = GetJob(jobName)
if not job then
return false, {
code = 'job_not_found',
message = jobName .. ' does not exist in core memory'
}
end
if not job.grades[grade] then
return false, {
code = 'job_missing_grade',
message = string.format('job %s does not have grade %s', jobName, grade),
}
end
local player = GetPlayerByCitizenId(citizenid) or GetOfflinePlayer(citizenid)
if not player then
return false, {
code = 'player_not_found',
message = string.format('player not found with citizenid %s', citizenid)
}
end
if player.PlayerData.jobs[jobName] == grade then
return true
end
if qbx.table.size(player.PlayerData.jobs) >= maxJobsPerPlayer and not player.PlayerData.jobs[jobName] then
return false, {
code = 'max_jobs',
message = 'player already has maximum amount of jobs allowed'
}
end
storage.addPlayerToJob(citizenid, jobName, grade)
if not player.Offline then
player.PlayerData.jobs[jobName] = grade
player.Functions.SetPlayerData('jobs', player.PlayerData.jobs)
TriggerEvent('qbx_core:server:onGroupUpdate', player.PlayerData.source, jobName, grade)
TriggerClientEvent('qbx_core:client:onGroupUpdate', player.PlayerData.source, jobName, grade)
end
if player.PlayerData.job.name == jobName then
SetPlayerPrimaryJob(citizenid, jobName)
end
return true
end
exports('AddPlayerToJob', AddPlayerToJob)```