Respawn Timer (disallow respawn without waiting x seconds)

There’s not much more I can say that isn’t in the title.

I’d like an admin only console command, though, that allows me to change the respawn time, so at times it could be no time at all.

You mean something like this?

– Set the maximum time in seconds before a player must respawn
maxdeathtime = 20;

– Create a hook for the GM:PlayerDeath() function that
– sets our two variables when the player dies
function player_initdeath( ply, wep, killer )

 ply.deathtime = 0; -- set the number of seconds dead
 ply.nextsecond = CurTime() + 1; -- set the time when we will add to the number of seconds dead

hook.Add( “PlayerDeath”, “player_initalize_dvars”, player_initdeath );

function playerforcerespawn( ply )

 if (CurTime()>ply.nextsecond) then              --If the current time has execeeded our next second add time
      if (ply.deathtime < maxdeathtime) then     --If the number of seconds dead less than our max death time
           ply.deathtime = ply.deathtime + 1;    --add one to the number of seconds dead
           ply.nextsecond = CurTime()+1;         --set our next death second add time
      else                                       --Otherwise
           ply.deathtime = nil;                  --erase our deathtime variable by seting to nil
           ply.nextsecond = nil;                 --erase our new add time storage by seting to nil
           ply:Spawn()                           --tell the player to spawn


hook.Add( “PlayerDeathThink”, “player_step_forcespawn”, playerforcerespawn

It makes them respawn in this certain time.

Here’s an addon to that script to have a console command.
if (ply:IsAdmin()||ply:IsSuperAdmin()) then

I don’t want to force them to respawn, I just want to have players not be allowed to respawn until x seconds has passed. Thank you for those scripts, though, I may find a use for them some time and will keep them in mind.

ply:IsAdmin() returns true for superadmins aswell.

I tried making one for you, but I ended up failing, the only way I could think of was to make an invisible derma menu with those methods:



Maybe you can get somewhere using those 2 functions

Here you go
CreateConVar(“respawnsecs”, 10, FCVAR_NOTIFY)

function SetRespawnSeconds(ply, cmd, args)
if ply:IsAdmin() then
RunConsoleCommand(“respawnsecs”, tonumber(args[1]))
else return end

concommand.Add(“setrespawnsecs”, SetRespawnSeconds)

local function RespawnPlayer(ply)
ply:ChatPrint(“You can respawn now”)

function ForcePlayerRespawn(ply)
if GetConVarNumber(“respawnsecs”) ~= 0 then
ply:ChatPrint(“You have to wait " … GetConVarNumber(“respawnsecs”) … " seconds before you can respawn”)
timer.Simple(GetConVarNumber(“respawnsecs”), RespawnPlayer, ply)

hook.Add(“PlayerDeath”, “ForcePlayerRespawn”, ForcePlayerRespawn)

Setting respawnsecs to 0 disables this script

Working awesome, thank you so much :slight_smile: