Skip to content

Extended: CBaseCombatWeapon

dounai2333 edited this page Dec 31, 2024 · 1 revision

Introduction

How to get this userdata:

Entity()
GetWeaponByIndex()
player:GetActiveWeapon()
player:GetWeapon()
player:GetWeapons()

tostring

tostring(weapon)

Format weapon to a proper string "Weapon [{index}][{classname}]".

Clip2

weapon:Clip2()

Returns how much secondary ammo is in the magazine.

Return: number

ForceShot

weapon:ForceShot()

Force the weapon fire a bullet, even player is not current using it.

BUG: This doesn't work on some classic pistols and grenade launchers.

Return: true or false

GetNextPrimaryFire

weapon:GetNextPrimaryFire()

Gets the next time the weapon can primary fire.

Time is based on CurTime().

Return: number

GetNextSecondaryFire

weapon:GetNextSecondaryFire()

Gets the next time the weapon can secondary fire.

Time is based on CurTime().

Return: number

GetOwner2

weapon:GetOwner2()

Same as original weapon:GetOwner(), but using different methods.

Return: player or nil

GetPrimaryAmmoType

weapon:GetPrimaryAmmoType()

Gets the primary ammo type of the given weapon.

Return: number

GetSecondaryAmmoType

weapon:GetSecondaryAmmoType()

Gets the ammo type of the given weapons secondary fire.

Return: number

GetWeaponID

weapon:GetWeaponID()

Get the weapon item id.

Return: number

GetWeaponType

weapon:GetWeaponType()

Get the weapon type (is pistol or rifle).

Return: number

GetWeaponViewModel

weapon:GetWeaponViewModel()

Returns the view model of the weapon.

Return: string

GetWeaponWorldModel

weapon:GetWeaponWorldModel()

Returns the world model of the weapon.

Return: string

LastShootTime

weapon:LastShootTime()

Returns the time since this weapon last fired a bullet in seconds.

Time is based on CurTime().

Return: number

SetClip1

weapon:SetClip1(clip1)

Lets you change the number of bullets in the given weapons primary clip.

clip1: number

SetClip2

weapon:SetClip2(clip2)

Lets you change the number of bullets in the given weapons secondary clip.

clip2: number

SetNextPrimaryFire

weapon:SetNextPrimaryFire(time)

Sets when the weapon can fire again.

Time is based on CurTime().

time: number

SetNextSecondaryFire

weapon:SetNextSecondaryFire(time)

Sets when the weapon can alt-fire again.

Time is based on CurTime().

time: number

SetWeaponViewModel

weapon:SetWeaponViewModel(model)

Set the view model of weapon.

model: string

SetWeaponWorldModel

weapon:SetWeaponWorldModel(model)

Set the world model of weapon.

model: string

SetWeaponPrimaryAmmo

weapon:SetWeaponPrimaryAmmo(ammo)

Change the primary ammo of weapon to a amount.

For ammo in the magazine, use weapon:SetClip1().

ammo: number

SetWeaponSecondaryAmmo

weapon:SetWeaponSecondaryAmmo(ammo)

Change the secondary ammo of weapon to a amount.

For ammo in the magazine, use weapon:SetClip2().

ammo: number

Clone this wiki locally