Player::giveWeapon: Difference between revisions

From RAGE Multiplayer Wiki
No edit summary
No edit summary
Line 12: Line 12:
   if (arr[0] == 'weapon') {
   if (arr[0] == 'weapon') {
     player.giveWeapon(3220176749, 1000); // Assault Rifle
     player.giveWeapon(3220176749, 1000); // Assault Rifle
  }
});
</syntaxhighlight>
'''Example 2'''. This example gives 2 weapons for player.
<syntaxhighlight lang="javascript">
mp.events.add('playerCommand', (player, command) => {
  let arr = command.split(' ');
  if (arr[0] == 'weapon') {
    player.giveWeapon([3220176749, 2210333304], 1000); // Assault Rifle, Carbine Rifle
   }
   }
});
});
</syntaxhighlight>
</syntaxhighlight>

Revision as of 16:50, 4 January 2017

This function gives a weapon for the player.

Syntax

player.giveWeapon(Number/Array weaponHash, Number ammo)

Example

Example 1. This example gives 1 weapon for player.

mp.events.add('playerCommand', (player, command) => {
  let arr = command.split(' ');
  if (arr[0] == 'weapon') {
    player.giveWeapon(3220176749, 1000); // Assault Rifle
  }
});

Example 2. This example gives 2 weapons for player.

mp.events.add('playerCommand', (player, command) => {
  let arr = command.split(' ');
  if (arr[0] == 'weapon') {
    player.giveWeapon([3220176749, 2210333304], 1000); // Assault Rifle, Carbine Rifle
  }
});