fivemesxluajob-systemroleplay
Create Custom Job in ESX — From 0 to Production
March 22, 2026
2 min read
3 views
Create Custom Job in ESX
Job system is the heart of almost every Roleplay server. This article will take you through creating a custom job from start to finish.
Step 1: Add Job to Database
-- add job
INSERT INTO jobs (name, label) VALUES ('mechanic', 'car mechanic');
-- Add grades
INSERT INTO job_grades (job_name, grade, name, label, salary, skin_male, skin_female) VALUES
('mechanic', 0, 'recruit', 'apprentice', 50, '{}', '{}'),
('mechanic', 1, 'worker', 'general mechanic', 100, '{}', '{}'),
('mechanic', 2, 'senior', 'senior mechanic', 150, '{}', '{}'),
('mechanic', 3, 'boss', 'chief mechanic', 200, '{}', '{}');
Step 2: Config
Config = {}
Config.JobName = 'mechanic'
Config.Blips = {
{
label = 'car repair shop',
coords = vector3(117.6, -1082.8, 29.2),
sprite = 446,
color = 5,
scale = 0.8
}
}
Config.DutyPoint = vector3(117.6, -1082.8, 29.2)
Config.RepairCost = 500 -- Basic repair cost
Config.BossMenuCoords = vector3(120.0, -1080.0, 29.2)
Step 3: Duty System
-- client.lua
local onDuty = false
-- Duty point interaction
Citizen.CreateThread(function()
while true do
local coords = GetEntityCoords(PlayerPedId())
local dist = GetDistanceBetweenCoords(coords, Config.DutyPoint, true)
if dist <= 2.0 then
DrawText3D(Config.DutyPoint.x, Config.DutyPoint.y, Config.DutyPoint.z + 0.5,
onDuty and '[E] leave work' or '[E] enter work'
)
if IsControlJustReleased(0, 38) then -- E
TriggerServerEvent('mechanic:toggleDuty')
end
Citizen.Wait(0)
else
Citizen.Wait(500)
end
end
end)
RegisterNetEvent('mechanic:setDuty')
AddEventHandler('mechanic:setDuty', function(state)
onDuty = state
exports['M2.Notify']:Notify(
state and 'success' or 'info',
state and 'entered work' or 'left work',
3000
)
end)
-- server.lua
RegisterNetEvent('mechanic:toggleDuty')
AddEventHandler('mechanic:toggleDuty', function()
local src = source
local xPlayer = ESX.GetPlayerFromId(src)
-- Check that it's a mechanic.
if xPlayer.getJob().name ~= Config.JobName then
TriggerClientEvent('M2.Notify:Notify', src, 'error', 'You are not a technician!', 3000)
return
end
local currentDuty = xPlayer.getMeta('onDuty') or false
local newDuty = not currentDuty
xPlayer.setMeta('onDuty', newDuty)
TriggerClientEvent('mechanic:setDuty', src, newDuty)
end)
Step 4: Paycheck
-- server.lua
local paycheckTimer = {}
AddEventHandler('playerJoining', function()
local src = source
paycheckTimer[src] = GetGameTimer()
end)
AddEventHandler('playerDropped', function()
paycheckTimer[source] = nil
end)
-- Paycheck every 30 minutes
Citizen.CreateThread(function()
while true do
Citizen.Wait(60000) -- checks every 1 minute
for _, playerId in ipairs(GetPlayers()) do
local src = tonumber(playerId)
local xPlayer = ESX.GetPlayerFromId(src)
if not xPlayer then goto continue end
local job = xPlayer.getJob()
if job.name == Config.JobName then
local onDuty = xPlayer.getMeta('onDuty') or false
if onDuty then
local salary = job.grade_salary
xPlayer.addMoney(salary)
TriggerClientEvent('M2.Notify:Notify', src, 'success',
'Receive salary $' .. salary, 5000)
end
end
::continue::
end
end
end)
Step 5: Boss Menu
-- client.lua
Citizen.CreateThread(function()
while true do
local coords = GetEntityCoords(PlayerPedId())
local dist = GetDistanceBetweenCoords(coords, Config.BossMenuCoords, true)
if dist <= 2.0 then
DrawText3D(Config.BossMenuCoords.x, Config.BossMenuCoords.y,
Config.BossMenuCoords.z + 0.5, '[G] Boss Menu')
if IsControlJustReleased(0, 47) then -- G
TriggerServerEvent('mechanic:openBossMenu')
end
Citizen.Wait(0)
else
Citizen.Wait(500)
end
end
end)
Summary
Creating custom jobs in ESX consists of 5 main parts: database setup, config, duty system, paycheck, and boss menu. Understand this pattern and you can create unlimited jobs.
Related Articles
Breaking: GTA Online อัพเดท "Money Fronts" — FiveM Server Owners ต้องทำอะไร?
Rockstar ปล่อย GTA Online อัพเดท Money Fronts มีผลกระทบต่อ FiveM servers บางส่วน นี่คือสิ่งที่ต้องทำทันทีหลังอัพเดท
Community Spotlight: Script และ Projects ที่น่าสนใจจาก FiveM Community
รวม scripts, tools และ projects ที่โดดเด่นจาก FiveM community ในช่วงที่ผ่านมา ตั้งแต่ free resources ถึง open-source projects
txAdmin อัพเดทใหม่ — Dashboard, Diagnostics และ Ban System ที่ดีขึ้น
txAdmin ซึ่งตอนนี้เป็นส่วนหนึ่งของ Cfx.re อย่างเป็นทางการ ได้รับการอัพเดทครั้งใหญ่ มี features ใหม่ที่ทำให้ Server Management ง่ายขึ้นมาก