Player:SetActiveWeapon
Description
Sets the player's active weapon. You should use CUserCmd:SelectWeapon or Player:SelectWeapon, instead in most cases.
This function will not trigger the weapon switch events or associated equip animations. It will bypass GM:PlayerSwitchWeapon and the currently active weapon's WEAPON:Holster return value.
Arguments
Example
local ply = Entity( 1 )
local prevWeapon = ply:GetActiveWeapon()
ply:SetActiveWeapon( NULL ) -- Holster the weapon, useful for manning the turrets.
local class
if ( prevWeapon:IsValid() ) then
class = prevWeapon:GetClass()
end
ply:SelectWeapon( class or "weapon_crowbar" ) -- switch to the last weapon or crowbar if prevWeapon is not valid