Interesting idea, however, your while loops can easily be replaced with $nick(#,0,aohvr) (/help $nick).
Not only this, but your script malfunctioned for me. On a channel with no ops it returned 100% (my server supporting the ~&@%+ prefix & me using version 6.21). And on a channel with only 3 ops, it returned 50%. I\'ve discovered that this is due to your formula, EX:
My channel has 15 users, 3 are ops:
//echo -a $calc(($nick(#,0) / $nick(#,0,o)) * 10) returned 50%
Why? Because, $nick(#,0) (The total amount, 15) is divided by the amount of ops (3). IE: 15 / 3 = 5. Next, you multiply this result by 10. So, 5 * 10 = 50, returning 50%.
Try using this formula (X = Number of Ops, Y = Total amount of nicks): X / Y * 100
So now, we replace the variables with our real amount of ops and real amount of users:
3 / 15 (0.2) * 100 = 20%, which is the correct answer.
Try implementing this somewhere in your script.