ENTITY/Use

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Don't undo this any further, IsValid( stuff ) is acceptable in all situations. Undo revision 25493 by Skere (talk))
Line 30: Line 30:
 
|Description=Kills any player that uses this entity.
 
|Description=Kills any player that uses this entity.
 
|Code=function ENT:Use( activator, caller )
 
|Code=function ENT:Use( activator, caller )
if caller:IsValid() and caller:IsPlayer() then  
+
if IsValid(caller) and caller:IsPlayer() then  
 
caller:Kill()
 
caller:Kill()
 
end
 
end
 
end
 
end
 
}}
 
}}

Revision as of 16:09, 6 October 2016

 ENTITY:Use( )

Contents

Description

Called when another entity uses this entity, example would be a player pressing "+use" this entity.

To change how often the function is called, see Entity:SetUseType.

Arguments

Entity activator

The initial cause for the input getting triggered.

Arguments

Entity caller

The entity that directly triggered the input.

Arguments

number useType

Use type, see USE_ Enums.

Arguments

number value

Any passed value.

Examples

Example

Kills any player that uses this entity.

function ENT:Use( activator, caller )
	if IsValid(caller) and caller:IsPlayer() then 
		caller:Kill()
	end
end


Personal tools
Navigation