Queue Tree problem

Hi everyone.

I have one queue tree whith many clients registered. I’d like to know if exists some scrpit to count how many clients I have, then add all “Limit At” of children (clients) and change the “Max Limit” of father’s group. This need to happen everytime that I added one user in the list.
Thanks in advance.

PHP and SQL.

But I need to my Mikrotik automatic update then, whithout any other server to do this. Somebody take one script to make it ?