Gamemode.PlayerTraceAttack

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerTraceAttack
SyntaxGM:PlayerTraceAttack( Player ply, CTakeDamageInfo dmginfo, Vector dir, Trace trace )
DescriptionTriggered when a player is hit by a trace, and damaged by it. Returning true will override it.
ReturnsBoolean Return false to do nothing.
Lua StateNewerShared.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerTraceAttack]Gamemode.PlayerTraceAttack [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionExample from sandbox's base code
Used onNewerShared.png
Code
 /*--------------------------------------------------------- 
    Name: gamemode:PlayerTraceAttack( ) 
    Desc: A bullet has been fired and hit this player 
 		 Return true to completely override internals 
 ---------------------------------------------------------*/ 
 function GM:PlayerTraceAttack( ply, dmginfo, dir, trace ) 
 
 	if ( SERVER ) then 
 		GAMEMODE:ScalePlayerDamage( ply, trace.HitGroup, dmginfo ) 
 	end 
 
 	return false 
 end 
OutputCalls ScalePlayerDamage when a player is hit by a trace.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox