Gamemode.ScalePlayerDamage

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NameScalePlayerDamage
SyntaxGM:ScalePlayerDamage( Player pl, Enum hitgroup, Ctakedamageinfo dmginfo )
DescriptionModifies the damage received by a player.
ReturnsCtakedamageinfo
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.ScalePlayerDamage]Gamemode.ScalePlayerDamage [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionPlayer take twice as much damage when shot in the head, and only half damage when shot in the limbs.
Used onNewerServer.png
Code
function ScaleDamage( ply, hitgroup, dmginfo )
 
	// More damage if we're shot in the head
	 if ( hitgroup == HITGROUP_HEAD ) then
 
		dmginfo:ScaleDamage( 2 )
 
	 end
 
	// Less damage if we're shot in the arms or legs
	if ( hitgroup == HITGROUP_LEFTARM ||
		 hitgroup == HITGROUP_RIGHTARM || 
		 hitgroup == HITGROUP_LEFTLEG ||
		 hitgroup == HITGROUP_RIGHTLEG ||
		 hitgroup == HITGROUP_GEAR ) then
 
		dmginfo:ScaleDamage( 0.50 )
 
	 end
 
end
 
hook.Add("ScalePlayerDamage","ScaleDamage",ScaleDamage)
OutputN/A


See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox