Garry's Mod Wiki

Weapon

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.

Methods

boolean Weapon:AllowsAutoSwitchFrom()
Returns whether the weapon allows to being switched from when a better ( Weapon:GetWeight ) weapon is being picked up.
boolean Weapon:AllowsAutoSwitchTo()
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!
number Weapon:Clip1()
Returns how much primary ammo is in the magazine. This is not shared between clients and will instead return the maximum primary clip size.
number Weapon:Clip2()
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!
number Weapon:GetActivity()
Returns the sequence enumeration number that the weapon is playing. This can return inconsistent results between the server and client.
string Weapon:GetHoldType()
Returns the hold type of the weapon.
number Weapon:GetMaxClip1()
Returns maximum primary clip size
number Weapon:GetMaxClip2()
Returns maximum secondary clip size
number Weapon:GetNextPrimaryFire()
Gets the next time the weapon can primary fire. ( Can call WEAPON:PrimaryAttack )
number Weapon:GetNextSecondaryFire()
Gets the next time the weapon can secondary fire. ( Can call WEAPON:SecondaryAttack )
number Weapon:GetPrimaryAmmoType()
Gets the primary ammo type of the given weapon.
string Weapon:GetPrintName()
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.
number Weapon:GetSecondaryAmmoType()
Gets the ammo type of the given weapons secondary fire.
number Weapon:GetSlot()
Returns the slot of the weapon. The slot numbers start from 0.
number Weapon:GetSlotPos()
Returns slot position of the weapon
string Weapon:GetWeaponViewModel()
Returns the view model of the weapon.
string Weapon:GetWeaponWorldModel()
Returns the world model of the weapon.
number Weapon:GetWeight()
Returns the "weight" of the weapon, which is used when deciding which Weapon is better by the engine.
boolean Weapon:HasAmmo()
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.
boolean Weapon:IsCarriedByLocalPlayer()
Returns whenever the weapon is carried by the local player.
boolean Weapon:IsScripted()
Checks if the weapon is a SWEP or a built-in weapon.
boolean Weapon:IsWeaponVisible()
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.
number Weapon:LastShootTime()
Returns the time since this weapon last fired a bullet with Entity:FireBullets in seconds. It is not networked.
Weapon:SendWeaponAnim( number act )
Forces weapon to play activity/animation.
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.
Weapon:SetNextSecondaryFire( number time )
Sets when the weapon can alt-fire again. Time should be based on CurTime.

Page Links


Special Pages


Wikis

?

Render Time: 31ms

DB GetPage 4
Generate Html 4
SaveChanges (1) 10
Render Body 0
Render Sidebar 10