Client
The ak47_lib provides unified client events that trigger across all supported frameworks (ESX, QBCore, Qbox). This allows you to listen for core player state changes without writing framework-specific event handlers.
ak47_lib:OnPlayerLoaded
Triggered when the player's character has completely loaded into the server and spawned. This event also safely fires if your resource is restarted while the player is already loaded in the server, ensuring your script always catches the active player state.
--- @param PlayerData table The full framework-specific player data object
--- @param resourceName string|nil The name of the resource if triggered by a resource restart
AddEventHandler('ak47_lib:OnPlayerLoaded', function(PlayerData, resourceName)
print("Player has successfully loaded!")
-- Example: Initialize script data or spawn UI elements
Lib47.PlayerLoaded = true
-- If you need to check framework-specific data
if Lib47.Framework == 'qb' or Lib47.Framework == 'qbx' then
print("Citizen ID: " .. PlayerData.citizenid)
elseif Lib47.Framework == 'esx' then
print("Identifier: " .. PlayerData.identifier)
end
end)ak47_lib:OnPlayerUnload
Triggered on the client when a player logs out or unloads their character (e.g., returning to the character selection screen). This event is standardized and dispatched across all supported frameworks (qb-core, qbx_core, and es_extended).
ak47_lib:OnJobUpdate
Triggered on the client whenever the player's job (or grade) is updated by the server.
ak47_lib:OnPlayerDataUpdate
Triggered on the client whenever the core player data object receives a synchronized update from the server. This often occurs when inventory items change, metadata updates, or money is added/removed.
ak47_lib:OnRemoveItem
Triggered on the client whenever an item is removed from the player's inventory or its total quantity decreases. This event automatically calculates inventory state changes across supported frameworks to ensure reliable tracking of lost or used items.
Last updated