QBCore is currently the most popular roleplay framework in the FiveM ecosystem. Its clean object-oriented architecture and modular design make it a favorite for modern servers. In this deep dive, we explore how QBCore.Functions.GetPlayer() operates under the hood.
1. The QBCore Player Object (Server-Side)
When a player connects, QBCore instantiates a table containing their character data, citizen ID, bank accounts, job grades, and inventory metadata:
local QBCore = exports['qb-core']:GetCoreObject()
RegisterNetEvent('roleplayly:server:giveReward', function()
local src = source
local Player = QBCore.Functions.GetPlayer(src)
if not Player then return end
-- Access citizen id and character name
local citizenId = Player.PlayerData.citizenid
local charName = Player.PlayerData.charinfo.firstname .. ' ' .. Player.PlayerData.charinfo.lastname
-- Safe financial addition
Player.Functions.AddMoney('bank', 500, 'mission-payout')
-- Trigger client notification
TriggerClientEvent('QBCore:Notify', src, 'Reward received: $500', 'success')
end)
2. Handling State Bags and Player Metadata
QBCore allows assigning dynamic metadata keys such as hunger, thirst, stress, and driver licenses without altering the core database schema directly.