RedM Natives

GET_ALL_PEDS

Returns all peds handles known to the server.

Hash0xB8584FEF
Runtime nameGetAllPeds
NamespaceCFX
SideServer
NameOfficial
Docs

Signature

object GET_ALL_PEDS();

Returns object — An object containing a list of peds handles.

Description

Cfx.re native reference

Returns all peds handles known to the server. The data returned adheres to the following layout:

[127, 42, 13, 37]

Usage

Lua
local retval = GetAllPeds()

-- always works, by hash
local retval = Citizen.InvokeNative(0xb8584fef, Citizen.ResultAsObject2(msgpack.unpack))
JavaScript and C#
JavaScript
const retval = GetAllPeds();

// by hash
const retval = Citizen.invokeNative('0xb8584fef', Citizen.returnResultAnyway(), Citizen.resultAsObject2());
C#
Function.Call((Hash)0xb8584fef);

Examples

LUA · Cfx.re native reference
-- This example prints information of every ped that has an owner.

for i, ped in ipairs(GetAllPeds()) do
    local pedOwner = NetworkGetEntityOwner(ped)
    if pedOwner > 0 then
       local playerName = GetPlayerName(pedOwner)
       local pedModel = GetEntityModel(ped)
       local pedArmour = GetPedArmour(ped)
       print("Ped : "..ped.." | Owner name : "..playerName.." | Model : "..pedModel.." | Armour : "..pedArmour)
    end
end

Sources

Cfx.re native reference

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