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

***

[SixL server API](../../README.md) / [events](../README.md) / IServerEvents

# Interface: IServerEvents

Server events: the events the server raises, with their handler signatures. Register a handler with `mp.events.add(name, fn)`.
Events your scripts raise themselves (`mp.events.call`) and events the clients send (`mp.events.callRemote` on the
client: the handler gets `(player, ...args)`) use plain string names and are not listed here.

## Remarks

Only the events SixL raises are listed. A RAGE MP handler may set `this.cancel`; SixL events cannot be cancelled.
`vehicleHornToggle` is not raised yet (the game has no horn query SixL can use).

## Example

```ts
mp.events.add('playerJoin', (player) => player.outputChatBox('Welcome'));
```

## Properties

### dummyEntityCreated

> **dummyEntityCreated**: (`dummy`) => `void`

A dummy entity was created. SixL addition.

#### Parameters

##### dummy

[`DummyMp`](../../world-entities/interfaces/DummyMp.md)

The dummy.

#### Returns

`void`

#### Remarks

SixL only on the server (RAGE MP raises this on the client).

#### Example

```ts
mp.events.add('dummyEntityCreated', (dummy) => { });
```

***

### dummyEntityDestroyed

> **dummyEntityDestroyed**: (`dummy`) => `void`

A dummy entity was destroyed. SixL addition.

#### Parameters

##### dummy

[`DummyMp`](../../world-entities/interfaces/DummyMp.md)

The dummy.

#### Returns

`void`

#### Remarks

SixL only on the server (RAGE MP raises this on the client).

#### Example

```ts
mp.events.add('dummyEntityDestroyed', (dummy) => { });
```

***

### entityCreated

> **entityCreated**: (`entity`) => `void`

An entity was created: a player joined, or a vehicle, ped, object, blip, marker, label, checkpoint or colshape
was made.

#### Parameters

##### entity

[`BaseEntityMp`](../../entity/interfaces/BaseEntityMp.md)

The new entity.

#### Returns

`void`

#### Example

```ts
mp.events.add('entityCreated', (entity) => console.log(entity.type, entity.id));
```

***

### entityDestroyed

> **entityDestroyed**: (`entity`) => `void`

An entity was destroyed or left: a player quit, or a vehicle, ped, object, blip, marker, label, checkpoint or
colshape was destroyed.

#### Parameters

##### entity

[`BaseEntityMp`](../../entity/interfaces/BaseEntityMp.md)

The entity that is gone.

#### Returns

`void`

#### Example

```ts
mp.events.add('entityDestroyed', (entity) => console.log('gone', entity.id));
```

***

### entityModelChange

> **entityModelChange**: (`entity`, `oldModel`) => `void`

An entity's `model` was changed by a script.

#### Parameters

##### entity

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

The entity.

##### oldModel

`string` \| `number`

The model before. Not raised for the first value, or when the value is unchanged.

#### Returns

`void`

#### Example

```ts
mp.events.add('entityModelChange', (entity, oldModel) => { });
```

***

### incomingConnection

> **incomingConnection**: (`ip`, `serial`, `login`) => `void`

A connection arrived and is being set up.

#### Parameters

##### ip

`string`

The client's address.

##### serial

`string`

The client's hardware serial (64 hex characters), or an empty string when it sent none.

##### login

`string`

The SixL lobby account name the player proved, or an empty string for a guest.

#### Returns

`void`

#### Remarks

The login is verified: the lobby signed the player's token, which the server checks offline against the
lobby's public keys, and the player signed this server's one-time challenge with their own key, so a modified
client cannot claim someone else's account. Any failure makes the player a guest. VI has no Social Club, so unlike RAGE MP there are no `rgscName`, `rgscId` or `gameType` arguments. The
serial is computed by the client; a modified client can forge it. It is the same on every SixL server for one
machine, so it helps bans and recognising a returning player, but it is not a guarantee of identity. The handler
cannot refuse the connection.

#### Example

```ts
mp.events.add('incomingConnection', (ip, serial, login) => console.log('connect from', ip, serial, login || 'guest'));
```

***

### packagesLoaded

> **packagesLoaded**: () => `void`

Every package of the server finished loading.

#### Returns

`void`

#### Example

```ts
mp.events.add('packagesLoaded', () => console.log('ready'));
```

***

### pedDamage

> **pedDamage**: (`ped`, `attacker`, `weapon`, `damage`, `bone`, `cause`) => `void`

A server ped took damage in a player's game, from any source. SixL addition.

#### Parameters

##### ped

[`PedMp`](../../world-entities/interfaces/PedMp.md)

The ped that was hurt.

##### attacker

[`PlayerMp`](../../player/interfaces/PlayerMp.md) \| [`VehicleMp`](../../vehicle/interfaces/VehicleMp.md) \| [`PedMp`](../../world-entities/interfaces/PedMp.md)

Who the reporting player says did it: a player, a server ped or a vehicle that player could see;
`undefined` for the world (a fall, an explosion, fire) or when the server cannot confirm the attacker.

##### weapon

`number`

The weapon hash of the game (0 = unknown). For a fall, an explosion or fire it names that source.

##### damage

`number`

The damage the game would have done, in health points.

##### bone

`number`

The bone that was hit: the hash of the bone's name, `0` when unknown.

##### cause

`number`

`1` a shot, `2` a vehicle, `0` anything else (the weapon hash says what).

#### Returns

`void`

#### Remarks

SixL only (RAGE MP has no such event). One client's statement, a request like `pedWeaponHit`: the game does
not hurt a server ped, and your script validates the damage, the distance, the rate and the attacker before it
applies anything. A modified client can send any damage up to 1000 about a ped it has in range. A shot by a player at the ped also raises `pedWeaponHit` (the
player's own claim) and, with the attacker and the weapon, this event. Every player that sees the ped may
report the same hit; the server raises it once per hit, and a rapid burst from one source can be merged
into fewer events than there were hits (reports of the same attacker, weapon and cause within 120 ms count as one).

#### Example

```ts
mp.events.add('pedDamage', (ped, attacker, weapon, damage) => { });
```

***

### pedWeaponHit

> **pedWeaponHit**: (`attacker`, `ped`, `hit`) => `void`

A player's shot hit a server ped. SixL addition.

#### Parameters

##### attacker

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The shooter.

##### ped

[`PedMp`](../../world-entities/interfaces/PedMp.md)

The ped hit.

##### hit

`{ damage, weapon, bone?, bodyPart?, point? }`: the damage the client reports, in health points; the
weapon hash (0 = unknown); and, when the server has them, the bone (hash of the bone's name, 0 = unknown), the
body part (0 unknown, 1 head, 2 torso, 3 and 4 arms, 5 and 6 legs) and the hit point `{ x, y, z }` in world
coordinates (metres).

###### bodyPart?

`number`

###### bone?

`number`

###### damage

`number`

###### point?

\{ `x`: `number`; `y`: `number`; `z`: `number`; \}

###### point.x

`number`

###### point.y

`number`

###### point.z

`number`

###### weapon

`number`

#### Returns

`void`

#### Remarks

SixL only (RAGE MP has no such event). A request, like `playerWeaponHit`: the script applies the damage to the ped itself. Unlike RAGE MP, the
game does not apply the damage. The bone, body part and point come with the current protocol; a test event may
leave them out.

#### Example

```ts
mp.events.add('pedWeaponHit', (attacker, ped, hit) => { ped.health -= hit.damage; });
```

***

### playerChat

> **playerChat**: (`player`, `text`) => `void`

A player wrote a chat line.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### text

`string`

The line as the player sent it.

#### Returns

`void`

#### Remarks

Same name on the client: none; the client has no chat, so `playerChat` is not raised there.

#### Example

```ts
mp.events.add('playerChat', (player, text) => mp.players.broadcast(`${player.name}: ${text}`));
```

***

### playerCommand

> **playerCommand**: (`player`, `command`) => `void`

A player entered a chat command that no `mp.events.addCommand` handler is registered for.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### command

`string`

The whole line without the slash, arguments included (`'tp 1 2 3'`).

#### Returns

`void`

#### Remarks

When a handler was registered for the command, only that handler runs and this event is not raised.
Same name on the client: none; the client has no command input, so `playerCommand` is not raised there.

#### Example

```ts
mp.events.add('playerCommand', (player, command) => player.outputChatBox(`Unknown: /${command}`));
```

***

### playerDamage

> **playerDamage**: (`player`, `healthLoss`, `armorLoss`) => `void`

A player lost health or armour.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### healthLoss

`number`

Health lost, in points.

##### armorLoss

`number`

Armour lost, in points.

#### Returns

`void`

#### Remarks

Raised once per loss, from the player's reported state; a heal raises nothing.

#### Example

```ts
mp.events.add('playerDamage', (player, healthLoss) => console.log(healthLoss));
```

***

### playerDeath

> **playerDeath**: (`player`, `reason`, `killer?`) => `void`

A player died.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### reason

`number`

The weapon hash of the last hit report younger than 5 s; `0` without one.

##### killer?

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player who made that hit; `undefined` without one, or when that player has left the server.

#### Returns

`void`

#### Remarks

The player's state carries neither the cause nor the killer: both come only from the server's own hit
reports, and a hit explains one death. Without such a report the reason is `0`, which is not a real cause, and the
killer is `undefined`. Raised once until the player's health is above 0 again.
Same name on the client: `playerDeath(player, reason, killer)`, raised there only for the local player, with the
reason always `0` and the killer always `undefined`.

#### Example

```ts
mp.events.add('playerDeath', (player, reason, killer) => { });
```

***

### playerEnterCheckpoint

> **playerEnterCheckpoint**: (`player`, `checkpoint`) => `void`

A player entered a checkpoint.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### checkpoint

[`CheckpointMp`](../../world-entities/interfaces/CheckpointMp.md)

The checkpoint.

#### Returns

`void`

#### Remarks

The radius is a 3D distance; the player must be in the checkpoint's dimension and the checkpoint must
be shown for them. Checked every ~100 ms. Same name on the client: none; the client does not raise
`playerEnterCheckpoint`.

#### Example

```ts
mp.events.add('playerEnterCheckpoint', (player, checkpoint) => { });
```

***

### playerEnterColshape

> **playerEnterColshape**: (`player`, `colshape`) => `void`

A player entered a colshape.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### colshape

[`ColshapeMp`](../../world-entities/interfaces/ColshapeMp.md)

The colshape.

#### Returns

`void`

#### Remarks

Checked every ~100 ms; the player must be in the colshape's dimension.

#### Example

```ts
mp.events.add('playerEnterColshape', (player, colshape) => { });
```

***

### playerEnterVehicle

> **playerEnterVehicle**: (`player`, `vehicle`, `seat`) => `void`

A player entered a vehicle.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle (`null` if the script host does not know it).

##### seat

`number`

The seat, 0 = driver.

#### Returns

`void`

#### Remarks

Same name on the client: `playerEnterVehicle(vehicle, seat)`, raised there only for the local player and
only for vehicles of the server.

#### Example

```ts
mp.events.add('playerEnterVehicle', (player, vehicle, seat) => { });
```

***

### playerExitCheckpoint

> **playerExitCheckpoint**: (`player`, `checkpoint`) => `void`

A player left a checkpoint.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### checkpoint

[`CheckpointMp`](../../world-entities/interfaces/CheckpointMp.md)

The checkpoint.

#### Returns

`void`

#### Remarks

Same rules as `playerEnterCheckpoint`.

#### Example

```ts
mp.events.add('playerExitCheckpoint', (player, checkpoint) => { });
```

***

### playerExitColshape

> **playerExitColshape**: (`player`, `colshape`) => `void`

A player left a colshape.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### colshape

[`ColshapeMp`](../../world-entities/interfaces/ColshapeMp.md)

The colshape.

#### Returns

`void`

#### Remarks

Not raised for a player who left the server.

#### Example

```ts
mp.events.add('playerExitColshape', (player, colshape) => { });
```

***

### playerExitVehicle

> **playerExitVehicle**: (`player`, `vehicle`, `seat`) => `void`

A player left a vehicle.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle (`null` if the script host does not know it).

##### seat

`number`

The seat the player had, 0 = driver.

#### Returns

`void`

#### Remarks

The seat is the one the player held before leaving, as RAGE MP's third argument.

#### Example

```ts
mp.events.add('playerExitVehicle', (player, vehicle, seat) => { });
```

***

### playerHurt

> **playerHurt**: (`player`, `attacker`, `weapon`, `damage`, `bone`, `cause`) => `void`

A player was hurt, with the source of the hurt. SixL addition.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player that was hurt.

##### attacker

[`PlayerMp`](../../player/interfaces/PlayerMp.md) \| [`VehicleMp`](../../vehicle/interfaces/VehicleMp.md) \| [`PedMp`](../../world-entities/interfaces/PedMp.md)

Who the player's client says did it: a player, a server ped or a vehicle that client could see;
`undefined` for the world (a fall, an explosion, fire) or when the server cannot confirm the attacker.

##### weapon

`number`

The weapon hash of the game (0 = unknown).

##### damage

`number`

The damage the game dealt, in health points.

##### bone

`number`

The bone that was hit: the hash of the bone's name, `0` when unknown.

##### cause

`number`

`1` a shot, `2` a vehicle, `0` anything else (the weapon hash says what).

#### Returns

`void`

#### Remarks

SixL only (RAGE MP has no such event). Raised from the hurt player's own report, next to the
`playerDamage` that follows from its reported health; `playerDamage` has the amounts, this has the source. It also
notes the attacker and the weapon for the player's next `playerDeath` (killer and reason); a vehicle's killer is the
player driving it. The damage is already done in the game, but who did it is the client's word: check it before you reward a kill.

#### Example

```ts
mp.events.add('playerHurt', (player, attacker, weapon, damage) => { });
```

***

### playerJoin

> **playerJoin**: (`player`) => `void`

A player connected (before the client is ready).

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

#### Returns

`void`

#### Remarks

Same name on the client: `playerJoin(player)`, raised there when the player comes into the client's range
for the first time. The server's event is for every connection; the client's only for players in range.

#### Example

```ts
mp.events.add('playerJoin', (player) => console.log(player.name));
```

***

### playerQuit

> **playerQuit**: (`player`, `exitType`, `reason`) => `void`

A player left the server.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player (already removed from `mp.players`).

##### exitType

`string`

How the connection ended: `'disconnect'` (the player left), `'timeout'` (the link was lost) or
`'kicked'` (the server removed the player: a kick or a ban).

##### reason

`string`

The text the player was told when kicked or banned; an empty string otherwise.

#### Returns

`void`

#### Remarks

Raised before `entityDestroyed` for the same player. The player is no longer in `mp.players`, but the
object it was is still readable.
Same name on the client: `playerQuit(player)`, raised there only for a player that was in the client's range.

#### Example

```ts
mp.events.add('playerQuit', (player, exitType, reason) => console.log(player.name, 'left:', exitType, reason));
```

***

### playerReachWaypoint

> **playerReachWaypoint**: (`player`) => `void`

A player reached the waypoint set on the map.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

#### Returns

`void`

#### Remarks

Partial: the player's client sees the waypoint go away with the player within 50 m of it (asked once
a second while the client is connected and its runtime runs, whether or not a client script listens) and tells the
server; not yet confirmed in the game.

#### Example

```ts
mp.events.add('playerReachWaypoint', (player) => player.outputChatBox('You are there'));
```

***

### playerReady

> **playerReady**: (`player`) => `void`

A player's client is ready: the server has its PlayerReady packet, so the player's language is known now.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

#### Returns

`void`

#### Remarks

Raised when the client's PlayerReady packet arrives, which is after its welcome and after the save's
load-in scene has finished. A teleport or `player.spawn()` in the handler is safe. `playerSpawn` follows right
after.
Same name on the client: `playerReady()` (no arguments), raised there once the server has welcomed the client and
the load-in scene has finished.

#### Example

```ts
mp.events.add('playerReady', (player) => player.spawn(new mp.Vector3(0, 0, 70)));
```

***

### playerSpawn

> **playerSpawn**: (`player`) => `void`

A player spawned: when the client became ready and after every `player.spawn()`.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

#### Returns

`void`

#### Remarks

Raised right after `playerReady` for the first spawn of a session, and again on every respawn.
Same name on the client: `playerSpawn(player)`, raised there only for the local player, and only after a death.

#### Example

```ts
mp.events.add('playerSpawn', (player) => { player.health = 100; });
```

***

### playerStartEnterVehicle

> **playerStartEnterVehicle**: (`player`, `vehicle`, `seat`) => `void`

A player started to get into a vehicle.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle (`null` if unknown).

##### seat

`number`

The seat, 0 = driver.

#### Returns

`void`

#### Remarks

Partial: there is no "started" packet from the client. The event is raised when the client's request to
get in arrives, before the seat is granted. It cannot be cancelled.

#### Example

```ts
mp.events.add('playerStartEnterVehicle', (player, vehicle, seat) => { });
```

***

### playerStartExitVehicle

> **playerStartExitVehicle**: (`player`) => `void`

A player started to get out of a vehicle.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

#### Returns

`void`

#### Remarks

Partial: there is no "started" packet from the client. The event is raised when the client's request to
get out arrives, before the seat is freed. It cannot be cancelled.

#### Example

```ts
mp.events.add('playerStartExitVehicle', (player) => { });
```

***

### playerStreamIn

> **playerStreamIn**: (`player`, `forPlayer`) => `void`

A player was streamed in for another player.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player who came into range.

##### forPlayer

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player who now sees them.

#### Returns

`void`

#### Example

```ts
mp.events.add('playerStreamIn', (player, forPlayer) => { });
```

***

### playerStreamOut

> **playerStreamOut**: (`player`, `forPlayer`) => `void`

A player was streamed out for another player.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player who left the range.

##### forPlayer

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player who no longer sees them.

#### Returns

`void`

#### Example

```ts
mp.events.add('playerStreamOut', (player, forPlayer) => { });
```

***

### playerWeaponChange

> **playerWeaponChange**: (`player`, `oldWeapon`, `newWeapon`) => `void`

The weapon in a player's hand changed.

#### Parameters

##### player

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player.

##### oldWeapon

`number`

The previous weapon hash.

##### newWeapon

`number`

The new weapon hash.

#### Returns

`void`

#### Remarks

The hashes are GTA VI's own weapon hashes, not GTA V's.

#### Example

```ts
mp.events.add('playerWeaponChange', (player, oldWeapon, newWeapon) => { });
```

***

### playerWeaponHit

> **playerWeaponHit**: (`attacker`, `target`, `hit`) => `void`

A player's shot hit another player. SixL addition.

#### Parameters

##### attacker

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The shooter.

##### target

[`PlayerMp`](../../player/interfaces/PlayerMp.md)

The player hit.

##### hit

`{ bodyPart, damage, weapon }`: the body part, the damage the client reports and the weapon hash
(0 = unknown).

###### bodyPart

`number`

###### damage

`number`

###### weapon

`number`

#### Returns

`void`

#### Remarks

SixL only (RAGE MP has no such event). A request, not a fact: unlike RAGE MP's damage, the script must
validate it and apply the damage itself. It also notes the hit for the target's next `playerDamage` / `playerDeath`.

#### Example

```ts
mp.events.add('playerWeaponHit', (attacker, target, hit) => { target.health -= hit.damage; });
```

***

### serverShutdown

> **serverShutdown**: () => `void`

The server is shutting down.

#### Returns

`void`

#### Remarks

Handlers have about 0.2 s before the process stops.

#### Example

```ts
mp.events.add('serverShutdown', () => saveEverything());
```

***

### trailerAttached

> **trailerAttached**: (`vehicle`, `trailer`) => `void`

A trailer was hitched to a vehicle, or let go.

#### Parameters

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle that pulls.

##### trailer

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The trailer, or `null` when the vehicle let its trailer go.

#### Returns

`void`

#### Remarks

Raised when the trailer the driver's game reports changes. Only a trailer that is a server vehicle is
named; a trailer the game made by itself raises nothing. `vehicle.trailer` and `trailer.traileredBy` follow the
report. Not yet confirmed in the game.

#### Example

```ts
mp.events.add('trailerAttached', (vehicle, trailer) => { });
```

***

### vehicleDamage

> **vehicleDamage**: (`vehicle`, `bodyHealthLoss`, `engineHealthLoss`) => `void`

A vehicle lost health.

#### Parameters

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle.

##### bodyHealthLoss

`number`

Body health lost, in health points.

##### engineHealthLoss

`number`

Engine health lost, in health points.

#### Returns

`void`

#### Remarks

Raised once per loss, from the state the driver reports. Nothing is raised for a heal.

#### Example

```ts
mp.events.add('vehicleDamage', (vehicle, bodyLoss, engineLoss) => { });
```

***

### vehicleDeath

> **vehicleDeath**: (`vehicle`) => `void`

A vehicle was destroyed.

#### Parameters

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle.

#### Returns

`void`

#### Remarks

Raised when the dead flag of the driver's reported state turns on; once per death.

#### Example

```ts
mp.events.add('vehicleDeath', (vehicle) => vehicle.destroy());
```

***

### vehicleSirenToggle

> **vehicleSirenToggle**: (`vehicle`, `state`) => `void`

The siren of a vehicle was turned on or off.

#### Parameters

##### vehicle

[`VehicleMp`](../../vehicle/interfaces/VehicleMp.md)

The vehicle.

##### state

`boolean`

`true` when the siren is on.

#### Returns

`void`

#### Remarks

Raised when the siren the driver's game reports changes; the first report is compared with
`vehicle.siren`. A client or game version that does not report the siren raises nothing. Not yet confirmed in the game.

#### Example

```ts
mp.events.add('vehicleSirenToggle', (vehicle, state) => { });
```
