How to detect if a player logs out of the game in Minecraft?

I am building a Minecraft survival games map, in which the battle area is on a floating island. My friends discovered that if they are falling to the ground, they can quickly logout and log back in to escape fall damage and not die, thus cheating.

Is there anyway to detect if a player logs out so I can increment their Death score?

I'm building it vanilla, I'm trying to make a whole map automated with just command blocks and redstone, this is the last thing I need to do now.


First, you should set up a scoreboard objective of type stat.leaveGame:

/scoreboard objectives add JustLeft stat.leaveGame

When a player leaves the world, their JustLeft score will increase by 1 because of its type.

On a clock somewhere, you should then have:

/scoreboard players set @a[score_JustLeft_min=1] Death 1

To set the death score of players who have just relogged to 1. Followed by:

/scoreboard players set @a[score_Death_min=1] JustLeft 0

So that their JustLeft score is reset after their Death score is set, preventing them being continually killed.

@a only selects online players, so they should only have their Death score set and then reset when they rejoin the world, even though their JustLeft stat will increase to 1 straight away.


Here's the format for the Update Aquatic (1.13):

Adding Score /scoreboard objectives add JustLeft minecraft.custom:minecraft.leave_game

Clock Command 1 /scoreboard players set @a[scores={JustLeft=1..}] Death 1

Clock Command 2 /scoreboard players set @a[scores={Death=1..}] JustLeft 0

Adding to SirBenet's answer, if at all a player is looking to reset the Deaths score for any reason, simply do this: /scoreboard players set @a[scores={Death=1..}] Death 0

The command format changed dramatically after 1.12, and for the better it seems. Removing things like "/testfor" and "/testforblock" and replacing them with "execute if entity " or "execute if block X Y Z "

TIP: adding elipses (...) after the numeric value tells Minecraft to check all values at or above this one; in this example, the command is checking for anyone with score "Deaths" greater than or equal to 1.