Limiting A User To A Given Amount Of Traffic Using Queues - MikroTik Script RouterOS

I have users that never spend 100 mb daily but need the good speed, And i have users that would download the whole internet in a day if they could. This way 'easy' users will have good speed for browsing , chatting with camera, and some small downloads. And the 'bandwidth hungry' users will suffer slower speeds after they cross their 100MB during the day. But, thats not that bad , users can download during the night hours 1am-10am when I disable this script and allow higher speed, because the network is not at peak usage.

For the others information here is the complete script that is tested and works.

:local traf;
/queue simple
  :for i from=1 to= 254 do =  {
    :if ([/queue simple find target-addresses=("192.168.1." . $i)] != "") do={
      :set traf [get [find target-addresses=("192.168.1." . $i)] total-bytes]
      :if ($traf  > 104857600) do = {
        set [find target-addresses=("192.168.1." . $i)] max-limit= 32000/64000
      }
    }
  }
This script will check all the simple queues shearching their target adresses and will search a whole 192.168.1.0/24 subnet. It will read their total-bytes (recieved transmited) and will check them if they crosed a limit of 100 MB ( 104857600 bytes) If they did , they will be limited to lower speed (64k/64k)

You can change the subnet, the limit, and the lower speed acording to your needs.

It shoud be added a scheduler that will run this script every 5 minutes or so. Another scheduler to reset counters daily " /que simple reset-counters".

Limitations

If the MT box is reset the traffic counters will be reset and the speed will return to normal (e.g. power outage) -- someone confirm this?
If a similiar script were to be applied to a pppoe style connection, a simple disconnection by the user would reset the traffic counters.