Preventing player death?

So this is probably a really easy thing to implement, but i’m completely clueless on how to do it.

Can anyone give me a snippet (or tell me how) to prevent a player from respawning?

I’m making a gamemode, and what i want to have happen is when the player dies, he spectates until a certain function is called, like a round end function. when the round end function is called, it’ll send a derma dialog to the dead players to either:

  1. change they’re weapon kit
  2. change they’re team and weapon kit

Once the players click a button at the end of the dialog, it’ll “ready” them. when all players are ready, a new round starts, and everything you just read starts over. :slight_smile:

EDIT: Fixed title.

[lua]function GM:PlayerDeathThink( pl )

if (  pl.NextSpawnTime && pl.NextSpawnTime > CurTime() ) then return end

if ( pl:KeyPressed( IN_ATTACK ) || pl:KeyPressed( IN_ATTACK2 ) || pl:KeyPressed( IN_JUMP ) ) then

   return
	
end

end
[/lua]

I’m using this technique. Basically rewrote the PlayerDeathThink function. Instead of spawning the player when the player clicks, i just have it return (do nothing).

Posted here for those who might want it.

Placed in my init.lua

Modify and repost your code!