[**SixL server API**](../../README.md)

***

[SixL server API](../../README.md) / [world-entities](../README.md) / PedMp

# Interface: PedMp

A server-created ped (NPC).

## Example

```ts
const ped = mp.peds.new('mp_m_freemode_01', new mp.Vector3(0, 0, 70), { heading: 180 });
```

## Extends

- [`EntityMp`](../../entity/interfaces/EntityMp.md)

## Properties

### alpha

> **alpha**: `number`

Opacity, 0 (invisible) to 255 (opaque).

#### Remarks

Values are clamped to 0..255 and rounded down. Partial: the value reaches the clients as the entity
data `sixl:alpha` but the game does not show it yet.

#### Example

```ts
vehicle.alpha = 128;
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`alpha`](../../entity/interfaces/EntityMp.md#alpha)

***

### data

> **data**: `any`

The shared variables as properties: `entity.data.key` reads, `entity.data.key = value` sets.

#### Remarks

A view over [BaseEntityMp.getVariable](../../entity/interfaces/BaseEntityMp.md#getvariable) / [BaseEntityMp.setVariable](../../entity/interfaces/BaseEntityMp.md#setvariable): setting a key sends it
to clients exactly like `setVariable`.

#### Example

```ts
player.data.cash = 100;
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`data`](../../entity/interfaces/EntityMp.md#data)

***

### dimension

> **dimension**: `number`

The dimension the entity lives in: players see and stream only entities of their own dimension.

#### Remarks

Dimension 0 is the default world. For players it is applied at once and the streaming is recomputed;
for other entities it is picked up on the next tick. For [PlayerMp.isStreamed](../../player/interfaces/PlayerMp.md#isstreamed) dimension 0 counts as
global; for vehicles, peds and objects (`isStreamed`) the dimensions must be equal.

#### Example

```ts
player.dimension = 5;
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`dimension`](../../entity/interfaces/EntityMp.md#dimension)

***

### heading

> **heading**: `number`

The ped's heading, in degrees.

#### Remarks

Partial: the server keeps the new value but no update is sent to the clients.

#### Example

```ts
ped.heading = 90;
```

***

### id

> `readonly` **id**: `number`

The entity's id, unique within its pool (`mp.players`, `mp.vehicles` …).

#### Remarks

Ids are server-side and start at 0 or 1 per pool, so two entities of different kinds can share one.
The client's `remoteId` is this same number.

#### Example

```ts
const vehicle = mp.vehicles.at(vehicleId);
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`id`](../../entity/interfaces/EntityMp.md#id)

***

### look

> **look**: `string`[]

The ped's look: VI's outfit as three 16-digit hex strings `[c0, c1, c2]`; `null` until set.

#### Remarks

A SixL addition. Use a player's `look` to dress the ped like that player. The clients that stream the
ped in put it on, only on a ped of the same model as the look. Setting a value that is not three strings
throws a `TypeError`.

#### Example

```ts
ped.look = player.look;
```

***

### model

> **model**: `string` \| `number`

The entity's model.

#### Remarks

VI's model keys are 64-bit values and GTA V model names do not resolve in VI. Vehicles, peds and
objects report the model as it was given at creation, a name string (a hash that `mp.joaat` computed in this
run is turned back into its name; an unknown hash becomes its decimal string). Players report what the script set
(a VI key as a `"0x..."` string, a name or a hash; 0 until set). Setting it on a player reaches the clients: the
player's own game loads the model and puts it on the player, and every client reads it as that player's model (not
yet checked in the game); on a vehicle, ped or object it changes the server's copy and raises `entityModelChange`
but is not sent to clients.

#### Example

```ts
const model = vehicle.model;
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`model`](../../entity/interfaces/EntityMp.md#model)

***

### position

> **position**: [`Vector3`](../../common/interfaces/Vector3.md)

The entity's position in metres.

#### Remarks

Reading returns the script host's copy. Setting moves the entity: for players, vehicles, peds and
objects the new position is sent to the server (for peds the new position does not reach the clients yet).
A blip, marker, label or checkpoint streams the new position to the players.

#### Example

```ts
player.position = new mp.Vector3(0, 0, 70);
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`position`](../../entity/interfaces/EntityMp.md#position)

***

### type

> `readonly` **type**: `string`

The kind of entity.

#### Remarks

`'player'`, `'vehicle'`, `'ped'` or `'object'`.

#### Example

```ts
if (entity.type === 'vehicle') { }
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`type`](../../entity/interfaces/EntityMp.md#type)

***

### weapon

> **weapon**: `number`

The weapon the ped holds, as the game's hash; 0 for none.

#### Remarks

A SixL addition. Sent to the clients as the ped's data `sixl:weapon`; they put it in its hand when it
streams in. Setting a name (a string) hashes it with joaat; as for players, take VI's hashes: GTA V's names do
not exist in VI. Setting 0 or null takes the weapon away.

#### Example

```ts
ped.weapon = weaponHash;
```

## Methods

### destroy()

> **destroy**(): `void`

Removes the entity.

#### Returns

`void`

#### Remarks

For vehicles, peds and objects the entity is gone from its pool the moment `destroy()` returns
(`exists` is false at once) and `entityDestroyed` follows. Players cannot be destroyed: use `kick()`.

#### Example

```ts
vehicle.destroy();
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`destroy`](../../entity/interfaces/EntityMp.md#destroy)

***

### dist()

> **dist**(`position`): `number`

The distance from the entity to a point or another entity.

#### Parameters

##### position

[`IVector3`](../../common/interfaces/IVector3.md) \| \{ `position`: [`IVector3`](../../common/interfaces/IVector3.md); \}

A point (anything with `x`, `y`, `z`, metres) or an entity (anything with `position`).

#### Returns

`number`

The 3D distance in metres.

#### Example

```ts
if (player.dist(shop.position) < 3) { }
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`dist`](../../entity/interfaces/EntityMp.md#dist)

***

### distSquared()

> **distSquared**(`position`): `number`

The squared distance (no square root: cheaper for comparisons).

#### Parameters

##### position

[`IVector3`](../../common/interfaces/IVector3.md) \| \{ `position`: [`IVector3`](../../common/interfaces/IVector3.md); \}

A point (anything with `x`, `y`, `z`, metres) or an entity (anything with `position`).

#### Returns

`number`

The squared 3D distance, metres squared.

#### Example

```ts
if (player.distSquared(point) < 25) { }
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`distSquared`](../../entity/interfaces/EntityMp.md#distsquared)

***

### getOwnVariable()

> **getOwnVariable**\<`T`\>(`name`): `T`

Reads a variable only this player's client sees (set with [EntityMp.setOwnVariable](../../entity/interfaces/EntityMp.md#setownvariable)).

#### Type Parameters

##### T

`T` = `any`

#### Parameters

##### name

`string`

The variable's key.

#### Returns

`T`

The value, or `undefined` when it was never set. Read from the script host's copy.

#### Example

```ts
const token = player.getOwnVariable('token');
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`getOwnVariable`](../../entity/interfaces/EntityMp.md#getownvariable)

***

### getVariable()

> **getVariable**\<`T`\>(`name`): `T`

Reads a shared variable (set by [BaseEntityMp.setVariable](../../entity/interfaces/BaseEntityMp.md#setvariable)).

#### Type Parameters

##### T

`T` = `any`

#### Parameters

##### name

`string`

The variable's key.

#### Returns

`T`

The value, or `undefined` when it was never set. Read from the script host's own copy: no round trip.

#### Example

```ts
const job = player.getVariable('job');
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`getVariable`](../../entity/interfaces/EntityMp.md#getvariable)

***

### giveWeapon()

> **giveWeapon**(`weapon`, `ammo?`): `void`

Gives the ped a weapon (the same as setting `weapon`).

#### Parameters

##### weapon

[`HashOrNumberOrString`](../../common/type-aliases/HashOrNumberOrString.md)

The game's weapon hash, a numeric string or a name (hashed with joaat).

##### ammo?

`number`

Ignored.

#### Returns

`void`

#### Remarks

A SixL addition.

#### Example

```ts
ped.giveWeapon(weaponHash, 100);
```

***

### setOwnVariable()

> **setOwnVariable**(`key`, `value`): `void`

Sets a variable that only this player's own client receives.

#### Parameters

##### key

`string`

The variable's key.

##### value

`any`

Any JSON-serialisable value.

#### Returns

`void`

#### Remarks

Only players send it: the client reads it with `mp.players.local.getOwnVariable(key)`. On vehicles,
peds and objects it is kept in the script host only.

#### Example

```ts
player.setOwnVariable('token', 'abc');
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`setOwnVariable`](../../entity/interfaces/EntityMp.md#setownvariable)

***

### setOwnVariables()

> **setOwnVariables**(`values`): `void`

Sets several own variables; the same as [EntityMp.setOwnVariable](../../entity/interfaces/EntityMp.md#setownvariable) for each key.

#### Parameters

##### values

[`KeyValueCollection`](../../common/type-aliases/KeyValueCollection.md)

An object of key to value.

#### Returns

`void`

#### Example

```ts
player.setOwnVariables({ token: 'abc', slot: 2 });
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`setOwnVariables`](../../entity/interfaces/EntityMp.md#setownvariables)

***

### setVariable()

> **setVariable**(`name`, `value`): `void`

Sets a shared variable on the entity.

#### Parameters

##### name

`string`

The variable's key.

##### value

`any`

Any JSON-serialisable value.

#### Returns

`void`

#### Remarks

The script's own copy changes at once. Players, vehicles, peds and objects also send it to the
clients that have the entity streamed in (with the size and rate limits of the server; a refused change is
logged by the script host and the local copy stays). Colshapes and dummies keep it on the server only.
Blips, markers, labels and checkpoints send it with their other data.

#### Example

```ts
vehicle.setVariable('fuel', 42);
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`setVariable`](../../entity/interfaces/EntityMp.md#setvariable)

***

### setVariables()

> **setVariables**(`values`): `void`

Sets several shared variables at once; the same as calling [BaseEntityMp.setVariable](../../entity/interfaces/BaseEntityMp.md#setvariable) for each key.

#### Parameters

##### values

[`KeyValueCollection`](../../common/type-aliases/KeyValueCollection.md)

An object of key to value.

#### Returns

`void`

#### Example

```ts
player.setVariables({ job: 'taxi', level: 3 });
```

#### Inherited from

[`EntityMp`](../../entity/interfaces/EntityMp.md).[`setVariables`](../../entity/interfaces/EntityMp.md#setvariables)
