There is no function to check the game mode
Even if you want to know by using setvariable, if the game mode is creative, the variable itself calls an error.