execute if score .host_mode settings matches 1 unless entity @s[tag=op] run return run tellraw @s {"text":"\nYou do not have permission to cycle maps in Host Mode! To toggle Host Mode an operator must type `/function pctf:host_mode/toggle`","color":"red"}
execute if score .time_till_tp countdown matches 1.. run return run tellraw @s {"text":"You cannot cycle maps during start countdown!","color":"red"}
execute if entity @e[tag=not_active,tag=finished] run return run function pctf:logic/lobby/left_in_edit

execute unless entity @e[type=marker,tag=map_lobby,tag=currently_selected] run tag @n[type=marker,tag=map_lobby,tag=!not_active,tag=finished] add currently_selected
execute as @n[tag=currently_selected] store result score #m_temp temp run scoreboard players get @s map_id
scoreboard players set #1 temp 1
execute store result storage pctf:map input.x int 1 run scoreboard players operation #m_temp temp += #1 temp
execute as @n[type=marker,tag=map_lobby,tag=currently_selected] at @s run function pctf:logic/lobby/cycle/loop with storage pctf:map input

#scoreboard players add .selected_map lobby 1
#execute if score .selected_map lobby > .total_maps lobby run scoreboard players set .selected_map lobby 1

execute as @a[tag=!playing] at @s run playsound minecraft:ui.button.click player @s ~ ~ ~ 0.5 2

execute store result storage pctf:map input.map_id int 1 run scoreboard players get .selected_map lobby
function pctf:logic/lobby/announce_map with storage pctf:map input