Garry's Mod Wiki

Player:Give

  Weapon Player:Give( string weaponClassName, boolean bNoAmmo = false )

Description

Gives the player a weapon.

While this function is meant for weapons/pickupables only, it is not restricted to weapons. Any entity can be spawned using this function, including NPCs and SENTs.

Arguments

1 string weaponClassName
Class name of weapon to give the player
2 boolean bNoAmmo = false
Set to true to not give any ammo on weapon spawn. (Reserve ammo set by DefaultClip)

Returns

1 Weapon
The weapon given to the player, if one was given. It will return NULL if the player already has the weapon, or the weapon entity (entity with given classname) doesn't exist.

Example

Gives the player a toolgun

Entity( 1 ):Give( "gmod_tool" )

Example

Removes all weapons and ammo from a player and gives a weapon_base SWEP with no ammo in it.

Entity( 1 ):StripWeapons() Entity( 1 ):StripAmmo() Entity( 1 ):Give( "weapon_base", true )