Player::allWeapons: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 1: Line 1:
Gets the players weapon's hash and ammo
Gets ammo from the current player's weapon
<br/>
<br/>
'''Note: this property is read-only.'''
'''Note: this property is read-only.'''
== Syntax ==
== Syntax ==
<pre>
<pre>
Object player.allWeapons;
Number player.weaponAmmo;
</pre>
</pre>


==Examples==
==Examples==
It will show your weapon's hash and ammo
It will show ammo from the current player's weapon
{{ServersideCode|
{{ServersideCode|
<pre>
<pre>
mp.events.addCommand('weapons', (player) => {
mp.events.addCommand('ammo', (player) => {
   const weapons = player.allWeapons;
   player.notify(`Ammo: ${player.weaponAmmo}`);
  for (let key in weapons) {
    player.notify(`Hash: ${key}, ammo: ${weapons[key]}`);
  }
});
});
</pre>
</pre>

Revision as of 23:46, 26 December 2020

Gets ammo from the current player's weapon
Note: this property is read-only.

Syntax

Number player.weaponAmmo;

Examples

It will show ammo from the current player's weapon

Server-Side
mp.events.addCommand('ammo', (player) => {
  player.notify(`Ammo: ${player.weaponAmmo}`);
});

See Also