Skip to main content

Ped::Ped

Not available on SYNC MP yet

This member is part of the RAGE:MP API but SYNC MP does not implement it yet (Server-side JavaScript). Calling it does nothing or throws.

Client-side function

Creates a new clientside ped. Use Player API to control peds actions.

JavaScript​

mp.peds.new(model, position, heading, dimension);

Parameters​

  • model: Hash (Ped Models)
  • position: Vector3
  • heading: Float
  • dimension: Integer

Example​

Client-Side

let ped = mp.peds.new(
mp.game.joaat('MP_F_Freemode_01'),
new mp.Vector3(100.0, -100.0, 25.0),
270.0,
mp.players.local.dimension
);

Legacy Syntax Variation​

The previous syntax for this function allowed you to specify a "streamedIn" callback. This has been removed in favor of the EntityStreamIn event, but you can add this polyfill to your client script to enable the previous syntax:

Client-Side

mp.peds.newLegacy = (hash, position, heading, streamIn, dimension) => {
let ped = mp.peds.new(hash, position, heading, dimension);
ped.streamInHandler = streamIn;
return ped;
};

mp.events.add("entityStreamIn", entity => {
if (entity.streamInHandler) {
entity.streamInHandler(entity);
}
});
Server-side function

Creates a new serverside static or dynamic ped.
Dynamic peds are synchronised/controlled by the player that your gamemode manually assigns and can be reassigned at any moment.
Use clientside Player API on peds to setup tasks. Tasks have to be executed by a player controlling ped.

JavaScript​

mp.peds.new(model, position,
{
dynamic: dynamic,
frozen: frozen,
invincible: invincible
});

Parameters​

  • model: Hash (Ped Models)
  • position: Vector3
  • dynamic: Boolean: true - synced by controller, false - static
  • frozen: Boolean
  • invincible: Boolean

Example​

Server-Side

let dynamicPed = mp.peds.new(mp.joaat('mp_m_freemode_01'), mp.players.at(0).position, {dynamic:true});
dynamicPed.controller = mp.players.at(0);

let staticPed = mp.peds.new(mp.joaat('player_zero'), mp.players.at(0).position,
{
dynamic: false, // still server-side but not sync'ed anymore
frozen: true,
invincible: true
});