They hit another player, or were hit by one, in the last 15 seconds
command /spawn:
trigger:
if player is in combat:
send "&cNot while you are fighting."
stop
teleport player to spawn of world "world" after 3 seconds unless they move
HyperScript keeps track of two things about every player by itself, so that a script only has to ask.
Syntax
Meaning
<who> is in combat
They hit another player, or were hit by one, in the last 15 seconds
<who> is afk
They have done nothing for 5 minutes: not moved, looked around, clicked, chatted or run a command
put <who> in combat
Count them as fighting from now, as if they had been hit. for 30 seconds to say how long
take <who> out of combat
The fight is over for them now
teleport <who> to <location> after <duration>
Take them there once that time is over; it counts down on their action bar
teleport <who> to <location> after <duration> unless they move
The same, called off if they walk away meanwhile
command /spawn:
trigger:
if player is in combat:
send "&cNot while you are fighting."
stop
teleport player to spawn of world "world" after 5 seconds unless they move
on combat start:
send action bar "&cIn combat with %event.opponent%" to player while player is in combat
on player quit:
if player is in combat:
broadcast "&c%player.name% logged out in a fight."
on afk:
broadcast "&7%player.name% is away."
Both times are in config.yml: combat-time: "15s" and afk-time: "5m". 0 switches one off.
A fight is between players. A mob does not put anybody in combat; put victim in combat in on entity damage: does, if you want that.
on combat start: runs once when a fight begins, not at every hit, and on combat end: when it is over. %event.opponent% is who the fight is with.
on afk: and on afk return: run when a player goes away and comes back. Turning the head counts as doing something; being pushed along by water does not.
What a waiting teleport says is in config.yml under messages:, and can be changed or left empty. A second teleport ... after for the same player takes the place of the first.