Documentation

Player

Constructible This class can not be instantiated from your script. Do not try to use the `new` keyword on this class. Auto Destroy Instances of this class will be deleted automatically. Custom Properties You can extend instances of this class with your own properties.

Properties

Name Type Description
client RemoteClient read only the associated RemoteClient of the player
name string read only the Player's name
networkId number read only the network id of this entity. It is not unique across different entities and will be re-assigned once this entity was destroyed
health number the players current health
invulnerable boolean whether the player is invulnerable to damage
position Vector3f the Player's position in the game world
respawnPosition Vector3f the position where the player respawns upon calling Player#Respawn
rotation Vector3f the Player's rotation in the game world
aimPosition Vector3f the position the player aims at
weapons Array<PlayerWeapon> or undefined read only weapons in the inventory
selectedWeapon PlayerWeapon read only the currently selected(equipped) weapon
model number model name of the player
dimension number world dimension of the Player.
vehicle Vehicle or undefined read only the players current vehicle

Functions

Player.Kick(string reason)

Immediately kicks the Player from the Server.

Parameter

Name Type Description
reason string reason for kicking the Player. currently unused (cannot be seen by the Player)

Example

jcmp.events.Add('PlayerReady', player => {
  player.Kick('meow!');
});

Player.Respawn()

Respawns the Player. The position is stored in Player.respawnPosition

Example

jcmp.events.Add('PlayerDeath', player => {
  player.respawnPosition = player.position
  player.Respawn();
});    

Player.GiveWeapon(number weaponHash, number ammo, boolean equipNow)

Gives the Player a weapon.

returns: PlayerWeapon

Parameter

Name Type Description
weaponHash number the weapon's hash
ammo number desired ammunition. If the Player already has the weapon, it will increase the ammo by this number.
equipNow boolean whether the weapon should be equipped automatically.

Example

jcmp.events.Add('PlayerReady', player => {
  player.GiveWeapon(2307691279, 100, true);
});        

Stay informed

By becoming the newest member of our growing forums, we and hundreds of other players will always keep you up to date on everything JC3:MP related.