Revision Difference
Player:SetActiveWeapon#545923
<function name="SetActiveWeapon" parent="Player" type="classfunc">
<description>
Sets the player's active weapon. You should use <page>CUserCmd:SelectWeapon</page> or <page>Player:SelectWeapon</page>, instead in most cases.
This function will not trigger the weapon switch events or associated equip animations. It will bypass
<page>GM:PlayerSwitchWeapon</page> and the currently active weapon's <page>WEAPON:Holster</page> return value.
</description>
<realm>Server</realm>
<args>
<arg name="weapon" type="Weapon">The weapon to equip.</arg>
</args>
</function>
⤶
<example>⤶
<code>⤶
local ply = player.GetAll()[1]⤶
local prevweapon = ply:GetActiveWeapon()⤶
ply:SetActiveWeapon(NULL) //Holster the weapon, useful for manning the turrets.⤶
⤶
local class⤶
⤶
if(IsValid(prevweapon)) then⤶
class = prevweapon:GetClass()⤶
end⤶
ply:SelectWeapon(class or "weapon_crowbar") //switch to the last weapon or crowbar if prevweapon is not valid⤶
</code>⤶
</example>⤶