ScriptsAboutBlogToolsKnowledge BaseReviewsFAQBasketDocsSupport
ESXserver

xPlayer.setJob

ESX server documentation with a FiveM Lua example.

Summary

Sets an ESX player's job and grade on the server-side xPlayer object.

Returns

void

Parameters

jobstringThe job name.
gradenumberThe grade level.

Example

local xPlayer = ESX.GetPlayerFromId(src)
if xPlayer then
  xPlayer.setJob('police', 2)
end

Common pitfalls

  • Job must exist in the ESX jobs table (database).
  • Guard if xPlayer then — a nil xPlayer is the usual crash here.

Related functions

Related guides

Managing jobs on your server?

Viper Multi-Job lets players hold several jobs and switch between them with grade, salary and duty handled — QBCore, QBox and ESX, validated server-side.

See Viper Multi-Job →