Template:BasicCS2Weapon

From Valve Developer Community
Jump to navigation Jump to search

KeyValues

CS2 Weapon:

Is this weapon allowed to be picked up? (CanBePickedUp) <boolean>
Determines if players are able to pick up the weapon.

Flags

Start Constrained : [1]
Prevents the model from moving.
Deny Player Pickup : [2] !FGD
Prevents player from being able to pick up the weapon.

Inputs

CS2 Weapon:

SetAmmoAmount <integer>
For guns, sets the number of bullets in the active magazine. Does nothing for grenades. Behaves like SetClipPrimary.
SetReserveAmmoAmount <integer>
For guns, sets the number of bullets in reserve for reloading, clamping at the weapon's maximum (e.g. 90 for the weapon_ak47).
For grenades, sets their count, clamping at the current maximum depending on the convars ammo_grenade_limit_*; When setting to 0 or below while holding the grenade, the player no longer owns any, but the viewmodel stays. Negative values are clamped to 0 for guns.
ToggleCanBePickedUp <boolean>
Toggles whether the weapon can be picked up by players. Visually, nothing changes and there is no event if picking up fails. Hover texts like "[E] Swap for AK-47" remain in both cases.
SetClipPrimary <integer>
For guns, sets the number of bullets in the active magazine, clamping between 0 and its clip size; When setting to 0, the owner may start reloading automatically.
Does nothing for grenades.
SetClipSecondary <integer>
Icon-Bug.pngBug:Does nothing. Use SetReserveAmmoAmount instead.  [todo tested in ?]

Outputs

CS2 Weapon:

OnPlayerUse
Fires when a player +uses this weapon (!activator is the player.). Does not fire if the weapon is picked up successfully.
OnPlayerPickup
Fires when a player picks this weapon up (!activator is the player.).