players.giveWeapon
Gives a player a weapon, or more ammunition for one they already have. The game loads its model before the result is applied.
Signature
Section titled “Signature”players.giveWeapon(player: PlayerTarget, weaponId: number, ammo: number): Promise<ActionResult>Parameters
Section titled “Parameters”| Name | Type | Description |
|---|---|---|
player |
PlayerTarget |
The player, or their ID. |
weaponId |
number |
GTA:SA’s weapon ID, 0 to 46 (24 is the Desert Eagle, 31 the M4); all of them on Weapons. |
ammo |
number |
Rounds, 0 to 1,000,000. |
Returns
Section titled “Returns”A promise of an ActionResult: applied once the player’s game has carried it out, rejected with a code, or timeout after five seconds without an answer.
Example
Section titled “Example”Arm every player when they spawn.
import { players, server } from "nativemp";
server.on("playerSpawned", async ({ player }) => { await players.giveWeapon(player, 24, 50); // Desert Eagle await players.giveWeapon(player, 31, 200); // M4});Related
Section titled “Related”players.openParachute: deploy weapon46during an eligible fallplayers.removeAllWeapons: take every weapon awayPlayerSnapshot:weaponIdis the weapon in hand
A captured Player keeps this effect bound to its connection across awaits; see Async handlers.