Convert script version 5.x to version 3.x

Pessoal não estou conseguindo executar esse script na versão 3.x, alguém poderia me ajudar na adaptação.

#===============================

SCRIPT PGAVISO

#===============================
#==== VARIAVEIS
#===============================
#== IP MK-AUTH
:global MKAUTH "172.31.255.2";
#== PORTA SQUID
:global PORTA "3128";
#== INTERVALO DE AVISO EX: "1d" = 1dia, "1h" = 1hora, "1m" = 1minuto, "1s" = 1segundo
:global INTERVALO "2m";

#== LIST (nao altere)
:global AVISO "avisado";
:global PGAVISO "pgaviso";

#================================
#==== REMOVER AS REGRAS ANTIGAS DE AVISO
:foreach A in=[/ip firewall nat find where comment="$PGAVISO"] do={ /ip firewall nat remove $A };
:foreach B in=[/ip firewall filter find where comment="$PGAVISO"] do={ /ip firewall filter remove $B };

#===============================

#==== PGAVISO PPPOE

#===============================

:foreach ID in=[/ppp active find] do={
:foreach LOGIN in=[/ppp active get $ID name] do={
:foreach IP in=[/ppp active get $ID address] do={
:foreach IPLISTA in=[/ip firewall address-list find where address="$IP"] do={
:foreach LISTA in=[/ip firewall address-list find where list="$PGAVISO"] do={ \

#==== CONDICAO PARA ENTRAR NO AVISO

:if ($IPLISTA = "$LISTA") do={ \

#==== ADCIONAR NOVAS REGRAS DE AVISO

:delay 1s;
/ip firewall nat add action=dst-nat chain=dstnat comment="$PGAVISO" disabled=no dst-address="!$MKAUTH" src-address=$IP
src-address-list=!avisado protocol=tcp dst-port=80 to-addresses=$MKAUTH to-ports=$PORTA;

/ip firewall filter add action=add-src-to-address-list address-list=$AVISO address-list-timeout="$INTERVALO" chain=forward
comment="$PGAVISO" disabled=no dst-address="$MKAUTH" src-address=$IP dst-port=90 protocol=tcp;

:log info "========================================";
:log warning " adicionando regras de pgaviso para <pppoe-$LOGIN> ";
:log info "========================================";
:delay 1s;

};
};
};
};
};
};
#==== FIM PGAVISO PPPOE ================

Install 4.17 and the script work