WEAPON/AcceptInput
From Garry's Mod
WEAPON:AcceptInput( )
Contents |
Description
Called when another entity fires an event to this entity.
Arguments
string inputName
The name of the input that was triggered.
Arguments
Entity activator
The initial cause for the input getting triggered.
Arguments
Entity called
The entity that directly trigger the input.
Arguments
string data
The data passed.
Returns
Should we suppress the default action for this input?
Examples
Example
A workaround for weapons created by maps not taking into account spawnflags.
function SWEP:AcceptInput( name, activator, caller, data ) -- Check for input and spawnflag if ( name == "ConstraintBroken" && self:HasSpawnFlags( 1 ) ) then -- Freeze the weapon local phys = self:GetPhysicsObject() if ( IsValid( phys ) ) then phys:EnableMotion( false ) end -- Remove the spawnflag so it doesn't freeze the weapon when it is dropped local newflags = bit.band( self:GetSpawnFlags(), bit.bnot( 1 ) ) self:SetKeyValue( "spawnflags", newflags ) end end