# Custom Limit Bandwidth Hotspot With Queue Tree - MikroTik Script RouterOS

    How To Custom Limit Bandwidth Hotspot With Queue Tree

    1. The Rate Limit (rx / tx) is left blank
    2. If using the user manager, just enter the hotspot profile name into the Group name on usermanager, don't forget to leave the Rate limit blank
    3. Adjust the parent name, in my example I use "7.ALL HTSPOT"

    When the user logs in. This script will automatically add new input to the queue tree and mangle, and will delete it again when the user logs out. shortcomings of this script I made uploads and downloads in one package, if you want to separate, please modify it as needed :)

    # SCRIPT ON LOGIN

    :local datetime [/system clock get date];
    :local timedate [/system clock get time];
    [/ip firewall mangle add action=mark-packet chain=prerouting dst-address="$address" new-packet-mark=("paket-"."$address") passthrough=no comment=("paket-"."$address")];
    [/ip firewall mangle add action=mark-packet chain=forward dst-address="$address" new-packet-mark=("paket-"."$address") passthrough=no comment=("paket-"."$address")];
    [/queue tree add max-limit=2M name=("$user"." -> "."$address") comment=("Login at: [ $timedate - $datetime ] From: [ $interface ] Mac: [ ".$"mac-address"." ]") packet-mark=("paket-"."$address") queue="HS-Down" parent="7.ALL HOTSPOT"];
    :log warning ("--> [ $user ] Login at: [ $timedate - $datetime ] From: [ $interface ] Mac: [ ".$"mac-address"." ]")

    # SCRIPT ON LOGOUT

    /queue tree remove [find packet-mark=("paket-"."$address")] ;
    /ip firewall mangle remove [find where comment=("paket-"."$address")]
    :log warning ("--> [ $user ] Logout at: [ $timedate - $datetime ] From: [ $interface ] Mac: [ ".$"mac-address"." ]")
    Credit: www.o-om.com