RedM Natives

GET_PLAYER_PED

Used to get the player's Ped Entity ID when a valid playerSrc is passed.

Hash0x6E31E993
Runtime nameGetPlayerPed
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

Entity GET_PLAYER_PED(char* playerSrc);

Parameters

NameTypeDescription
playerSrcchar*

The player source, passed as a string.

Returns Entity — Returns a valid Ped Entity ID if the passed `playerSrc` is valid, `0` if not.

Description

Cfx.re native reference

Used to get the player's Ped Entity ID when a valid playerSrc is passed.

Usage

Lua
local retval = GetPlayerPed(playerSrc)

-- always works, by hash
local retval = Citizen.InvokeNative(0x6e31e993, playerSrc, Citizen.ResultAsInteger())
JavaScript and C#
JavaScript
const retval = GetPlayerPed(playerSrc);

// by hash
const retval = Citizen.invokeNative('0x6e31e993', playerSrc, Citizen.returnResultAnyway(), Citizen.resultAsInteger());
C#
int retval = Function.Call<int>((Hash)0x6e31e993, playerSrc);

Examples

LUA · Cfx.re native reference
-- Let's assume source is a valid ID
local pedId = GetPlayerPed(source);

-- If pedId is valid (not equal to 0)
if pedId ~= 0 then
    -- Do something with this ped!
end

Sources

Cfx.re native reference

Something wrong or missing? Contribute a verified note — corrections ship through pull requests.