Player::allWeapons: Difference between revisions

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


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

Revision as of 23:48, 26 December 2020

Gets the players weapon's hash and ammo
Note: this property is read-only.

Syntax

Object player.allWeapons;

Examples

It will show your weapon's hash and ammo

Server-Side
mp.events.addCommand('weapons', (player) => {
  const weapons = player.allWeapons;
  for (let key in weapons) {
    player.notify(`Hash: ${key}, ammo: ${weapons[key]}`);
  }
});

See Also