Gamemode.DoPlayerDeath

From GMod Wiki

Revision as of 15:13, 17 February 2011 by BlackVoid (Talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search
Event Hook
Hook NameDoPlayerDeath
SyntaxGM:DoPlayerDeath( Player victim, Entity Attacker, Ctakedamageinfo DamageInfo )
DescriptionIs called when a player dies, this specifies exactly what should happen after the players death (ie create client ragdoll)
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.DoPlayerDeath]Gamemode.DoPlayerDeath [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionWhen the player dies, makes him into a ragdoll, adds his deaths and adds frags to the player who killed the player.(From the base)
Used onNewerServer.png
Code
 
/*---------------------------------------------------------
   Name: gamemode:DoPlayerDeath( )
   Desc: Carries out actions when the player dies 		 
---------------------------------------------------------*/
function GM:DoPlayerDeath( ply, attacker, dmginfo )
 
	ply:CreateRagdoll()
 
	ply:AddDeaths( 1 )
 
	if ( attacker:IsValid() && attacker:IsPlayer() ) then
 
		if ( attacker == ply ) then
			attacker:AddFrags( -1 )
		else
			attacker:AddFrags( 1 )
		end
 
	end
 
end
 
OutputN/A


Additional Notes

See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox