Samuel's Development, Official Documentation
  • 🎉Welcome
  • 📑Overview
    • Resources
      • Bobcat Weapon Heist
        • Installation Guide
        • Configuration
      • Traphouse Robbery
        • Installation Guide
        • Configuration
      • Pacific Bank Heist
        • Installation Guide
        • Configuration
      • Oxy Run
        • Installation Guide
        • Configuration
      • Dumpster Diving
        • Installation Guide
        • Configuration
        • Log Configuration
      • Warehouse Heist
        • Installation Guide
        • Configuration
      • Oil Rig
        • Installation Guide
        • Configuration
      • Beekeeping
        • Installation Guide
        • Configuration
        • Log Configuration
      • Yacht Robbery
        • Installation Guide
        • Configuration
      • Notify
        • Installation
        • Configuration
      • Cocaine Mission
        • Installation Guide
        • Configuration
      • Advanced Drug Sales
        • Installation Guide
        • Configuration
    • Library
      • Installation & Integration
      • Modules
        • Client
          • Callback
          • StartProgress
          • LoadAnim
          • LoadModel
          • LoadPtfxAsset
          • ShowNotification
          • SendEmail
          • PoliceDispatch
          • StartHack
        • Server
          • Callback
          • Name
          • Money
          • Logger
          • Inventory
          • HasGroup
          • GetPlayer
          • GetPlayers
          • GetPlayerByIdentifier
          • GetIdentifier
          • GetPlayerGender
          • CheckVersion
        • Shared
          • Array
          • Table
          • String
          • Math
          • Locale
            • JSON Example
          • AwaitLoad
          • Framework
  • 📚F.A.Q
    • How do I change Locales?!
    • How to add Police Alerts?!
    • What types of dirty money are supported?
Powered by GitBook
On this page
  • Overview
  • Parameters
  • Usage Example
  1. Overview
  2. Library
  3. Modules
  4. Server

GetPlayer

The SD.GetPlayer module provides a unified method to retrieve player objects across different frameworks by abstracting the framework-specific functionalities into a single interface. This standardization simplifies developer interactions with player objects, enhancing code portability and maintainability.

Overview

Purpose: Facilitates the retrieval of player objects using a server ID, regardless of the underlying gaming framework, by providing a consistent interface.

Returns: Player|nil: Returns the player object if available, or nil if the player is not found or in case of an error due to unsupported frameworks.

  • ESX: Utilizes ESX.GetPlayerFromId to fetch the player object using the server ID.

  • QB: Uses QBCore.Functions.GetPlayer to obtain the player object.

  • QBX: Employs exports.qbx_core:GetPlayer for QBX-specific data retrieval.

Parameters

  • source (number): The server ID of the player to retrieve. Returns:

Usage Example

local player = SD.GetPlayer(source)
if player then
    print('Player name:', player)
else
    print('Player not found or framework not supported.')
end

PreviousHasGroupNextGetPlayers

Last updated 1 year ago

📑