API for RAGE:MP


This page describes the API for the RAGE:MP modification. Our API provides fully analogous functionality to the original JavaScript API of RAGE:MP. Due to some minor issues, we had to rewrite some functions, but the return types remain original and belong to RAGE:MP.

localPlayer: Player


Get the current player. The object is an analog of mp.players.local.

logInfo(message: string): void


Add a message to the terminal. The function is an analog of mp.console.logInfo.

chatPush(message: string): void


Add a message to the text chat. The function is an analog of mp.gui.chat.push.

keyBind(keycode: integer, keydown: boolean, handler): void


Bind an action to a key press. The function is an analog of mp.keys.bind.

keyUnbind(keycode: integer): void


Unbind all actions from a key press. The function is an analog of mp.keys.unbind.

getPlayerAtRemoteId(remoteId: integer): Player


Get the player object by identifier. The function is an analog of mp.players.atRemoteId.

getVehicleAtRemoteId(remoteId: integer): Vehicle


Get the vehicle object by identifier. The function is an analog of mp.vehicles.atRemoteId.

getObjectAtRemoteId(remoteId: integer): Object


Get the object by identifier. The function is an analog of mp.objects.atRemoteId.

getPedAtRemoteId(remoteId: integer): Ped


Get the ped object by identifier. The function is an analog of mp.peds.atRemoteId.

getBlipAtRemoteId(remoteId: integer): Blip


Get the blip object by identifier. The function is an analog of mp.blips.atRemoteId.

Pools


getPlayers(): mp.players — get the array of players.
getVehicles(): mp.vehicles — get the array of vehicles.
getBlips(): mp.blips — get the array of blips.
getCheckpoints(): mp.checkpoints — get the array of checkpoints.
getColshapes(): mp.colshapes — get the array of colshapes.
getMarkers(): mp.markers — get the array of markers.
getObjects(): mp.objects — get the array of objects.
getPickups(): mp.pickups — get the array of pickups.
getLabels(): mp.labels — get the array of labels.
getBrowsers(): mp.browsers — get the array of browsers.
getCameras(): mp.cameras — get the array of cameras.

You can find documentation for all pool types on wiki.rage.mp.

Natives


invokeVoid(hash: string, …args: any): void — call a native without a return value.
invokeInt(hash: string, …args: any): integer — call a native with a return value of type integer.
invokeFloat(hash: string, …args: any): float — call a native with a return value of type float.
invokeString(hash: string, …args: any): string — call a native with a return value of type string.
invokeVec(hash: string, …args: any): Vector3 — call a native with a return value of type Vector3.

You can find a list of all native hashes on nativedb.