Gamemode.PlayerDeathThink

From GMod Wiki

Jump to: navigation, search
Event Hook
Hook NamePlayerDeathThink
SyntaxGM:PlayerDeathThink( Player Player )
DescriptionIs executed every server frame a player is dead
ReturnsNil
Lua StateNewerServer.png
BBCode[b][url=wiki.garrysmod.com/?title=Gamemode.PlayerDeathThink]Gamemode.PlayerDeathThink [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionCreates a force respawn system that will force a dead player to respawn in 10 seconds.
Used onNewerServer.png
Code
-- Set the maximum time in seconds before a player must respawn
local maxdeathtime = 10;
 
-- Create a hook for the GM:PlayerDeath() function that
-- sets our two variables when the player dies
function player_initdeath( ply, wep, killer )
 
     ply.nextspawn = CurTime() + maxdeathtime; -- set when we want to spawn
 
end
hook.Add( "PlayerDeath", "player_initalize_dvars", player_initdeath );
 
function playerforcerespawn( ply )
 
     if (CurTime()>=ply.nextspawn) then
          ply:Spawn()
          ply.nextspawn = math.huge
     end
 
end
 
hook.Add( "PlayerDeathThink", "player_step_forcespawn", playerforcerespawn );
OutputN/A


Additional Notes

See Also


Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox