WEAPON/Holster

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Original wording sounded confusing, sounded like it only EVER gets called serverside before OnRemove but thats not what its saying (I think??) Feel free to find a better way to word this)
m (Comma)
 
Line 4: Line 4:
 
{{Bug|Issue=2854|This is called twice for every holster clientside, one in [[Prediction|prediction]] and one not.}}
 
{{Bug|Issue=2854|This is called twice for every holster clientside, one in [[Prediction|prediction]] and one not.}}
  
{{Bug|Issue=3133|Before {{HookFunction|WEAPON|OnRemove}} is called this function is only called serverside.}}
+
{{Bug|Issue=3133|Before {{HookFunction|WEAPON|OnRemove}} is called, this function is only called serverside.}}
 
|Realm=Shared
 
|Realm=Shared
 
|Predicted=Yes
 
|Predicted=Yes

Latest revision as of 22:26, 2 October 2019

 WEAPON:Holster( )

Contents

Description

Called when weapon tries to holster.

BUG

This is called twice for every holster clientside, one in prediction and one not.

Issue Tracker: #2854

BUG

Before WEAPON:OnRemove is called, this function is only called serverside.

Issue Tracker: #3133

NOTE

This hook is predicted. This means that in singleplayer, it will not be called in the Client realm.

Arguments

Entity weapon

The weapon we are trying switch to.

Returns

boolean

Return true to allow weapon to holster

Examples

Example

Returns the weapon switched to when when the weapon is being holstered.

function SWEP:Holster( wep )
	if not IsFirstTimePredicted() then return end
	LocalPlayer():ChatPrint("Switched to: "..(wep.PrintName or wep:GetClass()))
end

Output:

Switched to Toolgun Switched to weapon_crowbar
Personal tools
Navigation