GetPlayerByIdentifier

The SD.GetPlayerByIdentifier module offers a streamlined and uniform method to retrieve player data across different gaming frameworks by using unique player identifiers. This module simplifies the task of accessing player objects in a consistent manner regardless of the underlying framework.

Overview

Purpose: Facilitates the retrieval of player data using unique identifiers, providing a uniform interface that abstracts away the differences between gaming frameworks like QB, ESX, and QBX.

Returns: A player's source or nil if the player does not exist or an error occurs due to unsupported frameworks.

  • QB: Utilizes QBCore.Functions.GetPlayerByCitizenId to fetch player data by their unique identifier.

  • ESX: Employs ESX.GetPlayerFromIdentifier to retrieve player information based on their unique system identifier.

  • QBX: Uses exports.qbx_core:GetPlayerByCitizenId for fetching player data, demonstrating integration with QBX custom extensions.

Parameters

identifier (string): The unique identifier of the player to retrieve.

Usage Example

local player = SD.GetPlayerByIdentifier('someUniqueIdentifier')
if player then
    print('Player found', player)
else
    print('Player not found or unsupported framework.')
end

Last updated