You can check how many license units available with this method $SYSTEM.License.LUAvailable()

And next depends on the kind of application, you develop. If it's some web application, and you have to achieve it for web session, I would try using %CSP.SessionEvents with OnLogin event, check how many license units are available and who is logging in, and decide to decline the login.

If you need it for some else ways of connections, I think the best place would be ZAUTHENTICATE.

Since 2016.2 there are no reasons to keep storing source code in XML. Even in transition process, I would recommend to store codebase based on the lowest supported version of platform.

Cache and IRIS able to export and import source code in UDL format, as seen in VSCode. 
 

If you would stay with XML format just because you’d like to keep history consistent, it can be solved by converting entire history in the like it was always in UDL.

Look at this page, it may help you in understanding how to configure it.

If you need to store classes and mac routines separately, you can use

{
  "objectscript.export": {
    "addCategory": true
  }
}

In the case of different behavior for different types, and place only mac routines to the specific folder, use this.

{ 
  "obejctscript.export": {
    "addCategory": false,
    "folder": {
      "mac": "mac"
    }
  }
}