Functions
The Player adapter provides unified access to player data on the client side, working seamlessly with both ESX and QBCore.
Functions
isLoggedIn
Checks if the player is logged in with a character.
FM.player.isLoggedIn()
Returns: boolean - True if player is logged in with a character
Example:
if FM.player.isLoggedIn() then
print("Player is logged in")
-- Your logic here
else
print("Player is not logged in yet")
end
getFullName
Returns the player's full name (firstname + lastname).
FM.player.getFullName()
Returns: string|nil - Player's full name or nil if not logged in
Example:
local name = FM.player.getFullName()
if name then
print("Player name:", name) -- Output: "John Doe"
end
getIdentifier
Returns the player's unique identifier.
FM.player.getIdentifier()
Returns: string|nil - Player's unique identifier (ESX identifier or QB citizen ID) or nil if not logged in
Example:
local identifier = FM.player.getIdentifier()
if identifier then
print("Player identifier:", identifier)
-- Use for database queries, etc.
end
getJob
Returns the player's current job data.
FM.player.getJob()
Returns: Job|nil - Player's job data or nil if not logged in
Job Structure:
{
name = "police", -- Job name
label = "Police", -- Display label
grade = 2, -- Job grade/rank number
gradeLabel = "Sergeant" -- Grade display label
}
Example:
local job = FM.player.getJob()
if job then
print(string.format("Job: %s (%s)", job.label, job.gradeLabel))
if job.name == "police" then
print("Player is a police officer")
end
end
getGang
Returns the player's current gang data.
FM.player.getGang()
Returns: Gang|nil - Player's gang data or nil if not logged in
Gang Structure:
{
name = "ballas", -- Gang name
label = "Ballas", -- Display label
grade = 1, -- Gang grade/rank number
gradeLabel = "Member" -- Grade display label
}
Example:
local gang = FM.player.getGang()
if gang then
print(string.format("Gang: %s (%s)", gang.label, gang.gradeLabel))
end
Exports
All player client functions are available as exports:
exports['fmLib']:player_isLoggedIn()
exports['fmLib']:player_getFullName()
exports['fmLib']:player_getIdentifier()
exports['fmLib']:player_getJob()
exports['fmLib']:player_getGang()
