NEED SCRIPTING HELP PLEASE queue based on userman user usag

Can anyone help me please..

I need to create a script that will check each user in /tool user-manager user for their total usage and then if they have gone over the specified amount that I put in the script then the script must create a queue that limits their speed to 50% or a specific number for the last specified amount of days in the script, it must also remove the queue if the user logs out.

It must check all the users every specified amount_(I will do that in the scheduler)_