How to automatically avoid no fly zone?(custom area)

is there any command doing that in qgc? if so? what is that? or if i make method? by using visual studio? can i solve this problem easily with fence? it is part of drone competition missions help!

You use a GeoFence. They are supported by PX P4o firmware but not ArduPilot although I think someone is working on it.