GM:ScalePlayerDamage

From Garry's Mod
Jump to: navigation, search
 GM:ScalePlayerDamage( )

Contents

Description

This hook allows you to change how much damage a player receives when one takes damage to a specific body part.

NOTE This is not called for all damage a player receives ( For example fall damage or NPC melee damage ), so you should use GM:EntityTakeDamage instead if you need to detect ALL damage.

Arguments

Player ply

The player taking damage.

Arguments

number hitgroup

The hitgroup where the player took damage. See HITGROUP_ Enums

Arguments

CTakeDamageInfo dmginfo

The damage info.

Returns

boolean

Return true to prevent damage that this hook is called for, stop blood particle effects and blood decals.

It is possible to return true only on client ( This will work only in multiplayer ) to stop the effects but still take damage.

Examples

Example

Makes the player take twice as much damage when shot in the head, and only half damage when shot in the limbs.

function GM:ScalePlayerDamage( ply, hitgroup, dmginfo )
	 if ( hitgroup == HITGROUP_HEAD ) then
		dmginfo:ScaleDamage( 2 ) // More damage when we're shot in the head
 	 else
		dmginfo:ScaleDamage( 0.50 )  // Less damage when shot anywhere else
	 end
end


Personal tools
Navigation