SixL client API / cameras / CameraMpPool

Interface: CameraMpPool

The script camera pool: mp.cameras. It holds the cameras the script made, and the gameplay camera.

Example

const cam = mp.cameras.new('default');

Constructors

Constructor

new CameraMpPool(name, position?, rotation?, fov?): CameraMp

Makes a script camera. It is inactive until CameraMp.setActive is called with true.

Parameters

name

string

The camera's name. 'default', the RAGE MP name of the default scripted camera and the RAGE MP name of the default scripted fly camera are accepted. Any other name gives the default scripted camera, because VI has no other named camera types.

position?

IVector3

The position in metres. Default: the origin.

rotation?

IVector3

The rotation in degrees (pitch, roll, yaw). Default: no rotation.

fov?

number

The vertical field of view in degrees. Default 50.

Returns

CameraMp

The new camera. The game makes it on the next frame.

Remarks

The camera is removed when the client leaves the server.

Example

const cam = mp.cameras.new('default', { x: 0, y: 0, z: 80 }, { x: -20, y: 0, z: 90 }, 50);

Properties

gameplay

readonly gameplay: GameplayCameraMp

The gameplay camera: the camera the game shows the player, as the latest frame has it. Read only.

Remarks

SixL: it has only the getters and GameplayCameraMp.doesExist; the setters of CameraMp are not on it.

Example

const pos = mp.cameras.gameplay.getCoord();

length

readonly length: number

The number of script cameras the client holds now.

Example

const count = mp.cameras.length;

Methods

at()

at(id): CameraMp

The camera with this client id, or undefined.

Parameters

id

number

The client's own number for the camera (from 0, reused after a camera is destroyed). It is not a handle.

Returns

CameraMp

The camera, or undefined when there is none with that id.

Example

const cam = mp.cameras.at(0);

exists()

exists(entity): boolean

Whether a script camera is still held by the pool.

Parameters

entity

number | CameraMp

A camera, or the client id of one (the id of CameraMpPool.at).

Returns

boolean

true while the camera exists; false once it is destroyed.

Example

if (mp.cameras.exists(cam)) { }

forEach()

forEach(callingFunction): void

Calls a function for every script camera the pool holds.

Parameters

callingFunction

(entity) => void

Called with each camera.

Returns

void

Example

mp.cameras.forEach((cam) => cam.setActive(false));

toArray()

toArray(): CameraMp[]

The script cameras the pool holds, as an array.

Returns

CameraMp[]

A new array of the cameras at the time of the call.

Example

const all = mp.cameras.toArray();