In principle, to avoid such confusion, you should, for example, put 2 spaces each time an if block starts. And in the content to be executed by the if, in addition to end, elseif, and then – also 2 spaces. Then the ends corresponding to the ifs will be on the same vertical line. This way, you can quickly determine where an end is missing.
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________