Prehook death event and prevent round end

I can detect when a player is about to die by hooking EntityTakeDamage and checking if the damage amount exceeds the health of the player.
However that method does not work when the player dies without taking damage from a slay.

How can I prehook a player’s death that works on both slays and damage?

In TTT, I can detect when the round ends with TTTEndRound, but is there a hook for preventing the round from ending?

Serverside: function GM:PlayerDeath ( victim, weapon, killer )

If the client needs to know, and do a net message:
[lua]hook.Add( “PlayerDeath”, “YourDeathTitle”, function( _v, _w, _k )

end )[/lua]

There’s another USEFUL one:

function GM:PlayerDeathThink( Player )

While the player is dead, this executes, serverside - RETURN FALSE to PREVENT respawn.

[lua]hook.Add( “PlayerDeathThink”, “YourDeathThinkTitle”, function( _p )

end )[/lua]

The PlayerDeath hook executes after the person dies. I need hook before they are considered dead to prevent the round from ending.

That would require a custom hack; hacky method of doing it. Probably the best way is to disable the round system so kills don’t end the round.

Then, on Death do the logic to decide whether or not you want to end the round or create a timer to end the round after x seconds to ensure the game continues.

You may want to look at the RoundStateChange function in cl_init.lua, and EndRound function in init.lua

This is a strange request though, why do you want to stop the round from ending? There may be a better way to do what you want to do??

I made a addon that turns the last round of TTT into a free for all death match.

To prevent the round from ending I made everyone into a traitor and 1 person as a detective.
It detects when a person is about to die and switches the detective to someone that isn’t about to die so that the round doesn’t end until the last 2 people kill each other.

The issue rises when a player is slayed. If that person is the detective, then it bypasses the damage hook and ends the round since the last innocent died.

I’m looking for a solution that will keep the addon portable and not as a deep hook.
If you have any Jerry Rig solutions for preventing the round from ending like I did, I’d love to hear them.

Interesting concept. Try this, edit those functions so that if it’s that last round, when it tries to switch the mode to game over, stop it from doing it, and ensure it stays as round active, any time it tries switching, set a new random detective, that might work… I’m not sure, I’d really have to dig in but modifying those 2 core files should do the trick…

to prevent the round from ending do:
ttt_debug_preventwin 1
in the console