# VEHICLE::_GET_ALL_WAGON_PASSENGERS

- **Hash:** `0x0E558D3A49D759D6`
- **Namespace:** VEHICLE
- **Runtime name (Lua/JS):** `GetAllWagonPassengers`
- **Side:** client (game native)
- **Name status:** community guess (may change)
- **Documentation:** described
- **Since game build:** 1207
- **Other names:** `_GET_ALL_TRAIN_WAGON_PASSENGERS`
- **URL:** https://natives.borderlinerp.com/natives/VEHICLE/_GET_ALL_WAGON_PASSENGERS

## Signature

```c
int _GET_ALL_WAGON_PASSENGERS(Vehicle wagon, ItemSet itemSet);
```

## Parameters

- `wagon` (`Vehicle`)
- `itemSet` (`ItemSet`)

## Returns

`int`

## Description

*Source: alloc8or RDR3 NativeDB*

Collects all passenger peds (excluding the driver) from the specified wagon-type vehicle (train wagon) and appends them to itemSet as indexed items. Returns the number of passengers added (0 if none / invalid / non-wagon).

Notes:
	- Only works on wagon entities (train wagons). Regular vehicles/coaches typically return 0.
	- Clear the itemset before calling.
	- If you also need the driver, query GET_DRIVER_OF_VEHICLE(wagon) and handle/add it separately (see scripts).
	- Resolve returned entries via indexed item helpers:
		Ped p = MISC::_GET_PED_FROM_INDEXED_ITEM(ITEMSET::GET_INDEXED_ITEM_IN_ITEMSET(i, itemSet));
		(or: Entity e = MISC::_GET_ENTITY_FROM_ITEM(...); then ENTITY::GET_PED_INDEX_FROM_ENTITY_INDEX(e)).
	- Wagon auto-population can be toggled via ENTITY::_0x119A5714578F4E05(wagon, bool); scripts disable it in some flows.

Example image: https://imgur.com/a/2V8Uk2K

Example (C++):
	ItemSet set = ITEMSET::CREATE_ITEMSET(true);
	ITEMSET::_CLEAR_ITEMSET(set);
	int count = VEHICLE::_GET_ALL_WAGON_PASSENGERS(wagon, set);
	for (int i = 0; i < count; ++i) {
		Ped p = MISC::_GET_PED_FROM_INDEXED_ITEM(ITEMSET::GET_INDEXED_ITEM_IN_ITEMSET(i, set));
		if (ENTITY::DOES_ENTITY_EXIST(p) && !ENTITY::IS_ENTITY_DEAD(p)) {
			// ...
		}
	}
	ITEMSET::DESTROY_ITEMSET(set);

*Source: VORPCORE RDR3natives*

Collects all passenger peds (excluding the driver) from the specified wagon-type vehicle and adds them as indexed items to the provided itemset.
Notes:
- Always clear the itemset before calling.
- Returns 0 if the wagon is empty or auto-population is disabled
  (ENTITY::_0x119A5714578F4E05(wagon, false)).
- Itemset may contain dead peds; filter with IS_ENTITY_DEAD if needed.
- Often used alongside wagon auto-population management.

## Usage

### Lua

```lua
local retval = GetAllWagonPassengers(wagon, itemSet)

-- always available, by hash
local retval = Citizen.InvokeNative(0x0E558D3A49D759D6, wagon, itemSet, Citizen.ResultAsInteger())
```

### JavaScript

```js
const retval = GetAllWagonPassengers(wagon, itemSet);

// by hash
const retval = Citizen.invokeNative('0x0E558D3A49D759D6', wagon, itemSet, Citizen.returnResultAnyway(), Citizen.resultAsInteger());
```

### C#

```csharp
int retval = Function.Call<int>((Hash)0x0E558D3A49D759D6, wagon, itemSet);
```

- The name is a community guess and may change. If the named call is missing in your client build, use `InvokeNative` with the hash — it always works.

*Sources: alloc8or RDR3 NativeDB, VORPCORE RDR3natives.*
