Player::setWeaponAmmo: Difference between revisions

From RAGE Multiplayer Wiki
(Created page with "Sets the amount of ammo for the selected weapon == Syntax == <syntaxhighlight lang="javascript"> player.setWeaponAmmo(weaponHash, ammo); </syntaxhighlight> === Parameters =...")
 
m (Replaced HTML with template)
 
(One intermediate revision by one other user not shown)
Line 3: Line 3:
== Syntax ==
== Syntax ==


<syntaxhighlight lang="javascript">
<pre>
player.setWeaponAmmo(weaponHash, ammo);
player.setWeaponAmmo(weaponHash, ammo);
</syntaxhighlight>
</pre>


=== Parameters ===
=== Parameters ===
Line 15: Line 15:
Gives you a weapon and lets you change the amount of ammo for that weapon. We use the assault rifle weapon has in this example.
Gives you a weapon and lets you change the amount of ammo for that weapon. We use the assault rifle weapon has in this example.


<syntaxhighlight lang="javascript">
{{ServersideCode|
<pre>
mp.events.addCommand('weapon', (player) => {
mp.events.addCommand('weapon', (player) => {
     player.giveWeapon(3220176749, 1000);
     player.giveWeapon(3220176749, 1000);
Line 23: Line 24:
     player.setWeaponAmmo(3220176749, parseInt(ammo));
     player.setWeaponAmmo(3220176749, parseInt(ammo));
});
});
</syntaxhighlight>
</pre>
}}


== See Also ==
== See Also ==
{{Player_block}}
{{Player_block}}

Latest revision as of 12:29, 26 October 2018

Sets the amount of ammo for the selected weapon

Syntax

player.setWeaponAmmo(weaponHash, ammo);

Parameters

  • weaponHash: Int
  • ammo: Int

Examples

Gives you a weapon and lets you change the amount of ammo for that weapon. We use the assault rifle weapon has in this example.

Server-Side
mp.events.addCommand('weapon', (player) => {
    player.giveWeapon(3220176749, 1000);
})

mp.events.addCommand('setammo', (player, _, ammo) => {
    player.setWeaponAmmo(3220176749, parseInt(ammo));
});

See Also