#detect if host
scoreboard players set @e[tag=dummy] login_count 0
execute @a ~ ~ ~ scoreboard players add @e[tag=dummy] login_count 1
execute @e[tag=dummy,scores={login_count=1}] ~ ~ ~ function stop


#give @s tag
tag @s add login
tag @s add login_reset


#detect if player was in active game
scoreboard players operation @s game_id -= @e[tag=dummy] game_id
execute @e[tag=dummy,scores={ingame=2}] ~ ~ ~ execute @a[tag=login,scores={game_id=0}] ~ ~ ~ tag @a[tag=login] add login_continue
tag @s[tag=login_continue] remove login_reset


#run functions
execute @a[tag=login_continue] ~ ~ ~ function login_continuegame
execute @a[tag=login_reset] ~ ~ ~ function login_resetplayer


#remove tags
tag @s remove login
tag @s remove login_reset
tag @s remove login_continue