Knowledge from the fieldRedM

_GET_ENTITIES_NEAR_POINT (0x59B57C4B06531E1E) p5 is entityType (1=ped, 2=vehicle, 3=object), not a bitmask

learning:28

_GET_ENTITIES_NEAR_POINT (0x59B57C4B06531E1E) p5 is entityType (1=ped, 2=vehicle, 3=object), not a bitmask

Context

The native docs for _GET_ENTITIES_NEAR_POINT (0x59B57C4B06531E1E) and _GET_ENTITIES_IN_VOLUME (0x886171A12F400B89) label the last int parameter only as p5 (int) / entityType (int) with no value list. Easy trap: people assume p5 is a bitmask and pass 3 expecting "peds + vehicles", get 0 back, and conclude the native is broken.

The fix

p5 is a single eEntityType value matching what GET_ENTITY_TYPE (0x97F696ACA466B4E0) returns:

  • 1 = peds
  • 2 = vehicles
  • 3 = objects (props)

Not a flag mask. There is no "all entities" value — call once per type if you need everything.

Verified usage (from working community scripts)

  • kibook/redm-interactions/client.lua — passes 3 to find props for interaction prompts
  • kibook/redm-instruments/client.lua — passes 3 for nearby instrument props
  • kibook/redm-fixanimals/client.lua — passes 1 for nearby animals/peds
  • DarrenJDocherty/RedM-Witnesses/client.lua — passes 1 for nearby ped witnesses

Standard pattern:

local itemset = CreateItemset(true)
local size = Citizen.InvokeNative(0x59B57C4B06531E1E,
    coords, radius, itemset, entityType, Citizen.ResultAsInteger())
if size > 0 then
    for i = 0, size - 1 do
        local entity = GetIndexedItemInItemset(i, itemset)
        -- ...
    end
end
if IsItemsetValid(itemset) then DestroyItemset(itemset) end

Gotchas

  1. Pass Citizen.ResultAsInteger() as the trailing marker in Lua — without it the return value can come back wrong. JS/TS hash-string invocations of underscore natives have similar return-type-inference issues; use the equivalent result-type hint.
  2. Client-side only. Walks streamed entities the local client knows about. Running in a server script returns 0 unconditionally.
  3. Empty result is legitimate. Type 3 (objects) over an empty field genuinely returns 0 — test with type 1 first since the local player ped will always be in range, which makes it a reliable smoke test for the call.
  4. CREATE_ITEMSET(true) marks the set script-managed (cleaned on resource stop); false is persistent. For short-lived nearby-entity queries either works, but pair with IsItemsetValid + DestroyItemset to be explicit.

Origin of the value list

Cross-referenced from umaruru's RDR2 prompt research gist and confirmed by GET_ENTITY_TYPE returning the same 1/2/3 values per Halen84's eEntityType enum.

Linked natives

  • _GET_ENTITIES_IN_VOLUME (0x886171A12F400B89)
  • _GET_ENTITIES_NEAR_POINT (0x59B57C4B06531E1E)
  • GET_ENTITY_TYPE (0x97F696ACA466B4E0)

Tags: entity, itemset, nearby, entitytype, props, peds, vehicles
Category: natives
Created: 2026-05-04T17:06:45.020Z

Back to documentation