Garry's Mod Wiki

WEAPON:AcceptInput

boolean WEAPON:AcceptInput( string inputName, Entity activator, Entity called, string data )

Description

Called when another entity fires an event to this entity.

Arguments

1 string inputName
The name of the input that was triggered.
2 Entity activator
The initial cause for the input getting triggered.
3 Entity called
The entity that directly trigger the input.
4 string data
The data passed.

Returns

1 boolean
Should we suppress the default action for this input?

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

Page Links


Special Pages


Wikis

?

Render Time: 174ms

DB GetPage 56
Generate Html 9
SaveChanges (1) 93
Render Body 0
Render Sidebar 12