Garry's Mod Wiki

Player:SetActiveWeapon

Player:SetActiveWeapon

  Player:SetActiveWeapon( Weapon weapon )

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

1 Weapon weapon
The weapon to equip.

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

Special Pages


Wikis

?

Render Time: 27ms

DB GetPage 3
Generate Html 5
SaveChanges (1) 9
Render Body 0
Render Sidebar 7