RTFO made a sketch, everything should work (after checking by moderators).
BUT! Since the state of the camera at this moment cannot be obtained, for the add-on to work, you need to assign a different key to toggle between the first and third person(check screenshot to addon)