GivePlayerWeapon

From GT-MP
Jump to: navigation, search
GivePlayerWeapon
Server-Side Function
Utilities-terminal.png Server-Side Csharp.png C#

Gives the given player a weapon of the given type. See also Weapons Models.


Syntax

In C#
Server-Side Function

public int API.givePlayerWeapon(Client player, WeaponHash weaponHash, int ammo, bool equipNow, bool ammoLoaded);
  • player: parameter input should be in Client type.
  • weaponHash: parameter input should be in WeaponHash type.
  • ammo: parameter input should be in int type.
  • equipNow: parameter input should be in bool type.
  • ammoLoaded: parameter input should be in bool type. (Will be removed in version 0.1.7)


Dialog-warning.png Note: The parameter "ammoLoaded" with the input type boolean was removed in the last published Open Beta version.


NOTE: This function returns data in int type.

Possible return values

  • 0 - Player already has that weapon, ammo was the same so no changes made.
  • 1 - Player did not have the weapon, nor any weapon which shares the same ammo. Weapon given.
  • 2 - Player did already have the weapon, ammo was not the same. Ammo changed.
  • 3 - Player did not have the weapon but a weapon which shares the same ammo. Weapon given and ammo updated.

Usage example(s)

// Use as: /weapon smg
[Command("weapon")]
public void WeaponCommand(Client sender, WeaponHash hash)
{
  API.givePlayerWeapon(sender, hash, 500, true);
}


References