This is a list of all methods only available for weapons. It is also possible to call Entity functions on weapons.
A list of available methods has been expanded in your navigation bar.
Returns whether the weapon allows to being switched from when a better ( Weapon:GetWeight ) weapon is being picked up.
Returns whether the weapon allows to being switched to when a better ( Weapon:GetWeight ) weapon is being picked up.
Weapon:CallOnClient( string functionName, string arguments )
Calls a SWEP function on client. This uses the usermessage internally, because of that, the combined length of the arguments of this function may not exceed 254 bytes/characters or the function will cease to function!
Returns how much primary ammo is in the magazine. This is not shared between clients and will instead return the maximum primary clip size.
Returns how much secondary ammo is in the magazine. This is not shared between clients and will instead return the maximum secondary clip size.
boolean Weapon:DefaultReload( number act )
Forces the weapon to reload while playing given animation. This will stop the Weapon:Think function from getting called while the weapon is reloading!
Returns the sequence enumeration number that the weapon is playing. This can return inconsistent results between the server and client.
Gets the next time the weapon can primary fire. ( Can call WEAPON:PrimaryAttack )
Gets the next time the weapon can secondary fire. ( Can call WEAPON:SecondaryAttack )
Returns the non-internal name of the weapon, that should be for displaying. If that returns an untranslated message (#HL2_XX), use language.GetPhrase to see the "nice" name.If SWEP.PrintName is not set in the Weapon or the Weapon Base then "<MISSING SWEP PRINT NAME>" will be returned.
Returns the "weight" of the weapon, which is used when deciding which Weapon is better by the engine.
Returns whether the weapon has ammo left or not. It will return false when there's no ammo left in the magazine and when there's no reserve ammo left. This will return true for weapons like crowbar, gravity gun, etc.
Returns whether the weapon is visible. The term visibility is not exactly what gets checked here, first it checks if the owner is a player, then checks if the active view model has EF_NODRAW flag NOT set.
Returns the time since this weapon last fired a bullet with Entity:FireBullets in seconds. It is not networked.
Weapon:SetClip1( number ammo )
Lets you change the number of bullets in the given weapons primary clip.
Weapon:SetClip2( number ammo )
Lets you change the number of bullets in the given weapons secondary clip.
Weapon:SetHoldType( string name )
Sets the hold type of the weapon. This function also calls WEAPON:SetWeaponHoldType and properly networks it to all clients. This only works on scripted weapons.Using this function on weapons held by bots will not network holdtype changes to clients if the world model is set to an empty string (SWEP.WorldModel = "").
Weapon:SetLastShootTime( number time = CurTime() )
Sets the time since this weapon last fired in seconds. Used in conjunction with Weapon:LastShootTime
Weapon:SetNextPrimaryFire( number time )
Sets when the weapon can fire again. Time should be based on CurTime. This will fire extra bullets if the time is set to less than CurTime.