Disable respawn

Hey

How do i disable respawn, like for 10 seconds.

pl.NextSpawnTime = CurTime() + 10

Okay, not what i expected, but what i asked about. So i gonna make it more clearly. How do i disable respawn until a boolean is true?

Look at the PlayerDeathThink hook in the base gamemode, where respawning is actually implemented. You can easily hook or override that, eg.

[Lua]
function GM:PlayerDeathThink(ply)
if not ply.SomeCond then return end
self.BaseClass:PlayerDeathThink(ply)
end
[/lua]

Exactly as Luni says; I’d recommend setting up a few helper functions ( you could also simply hook into PlayerDeathThink but if you’re writing a game-mode, it would be better to recode the hooks ): https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/spectating_players_system.lua.html

https://dl.dropboxusercontent.com/u/26074909/tutoring/_systems/playerselectspawn_system.lua.html

remove .html to view .lua

Luni’s code doesn’t work; you ideally ought to return a boolean value. You also don’t need to call the hook from within it’s base class again; that’s unnecessary. Also, I recommend you use

hook.Add instead of directly overwriting the hook. Use this code instead;

[lua]
some_boolean_value = true

hook.Add( “PlayerDeathThink”, “prevent_spawn”, function( ply )
return some_boolean_value
end )
[/lua]

I wouldn’t recommend this at all… When creating hooks, you alter specific behavior but with this hook you’re essentially overwriting all other hooks and the GM function because you return non-nil… If the op is writing a game-mode and only wants people to respawn at round-start, then something like this would work but I’d still recommend using GM: instead of hook so that the behavior can be altered by addons…