Since it's per connection, the way the script works is perfect for it.
Technically if you wanted to make it more complex, you could allow it to spam commands faster when it was nowhere near the limit. The problem with that is that you have no way to know how the limit exactly works. At what point the server resets the count or decreases it, or at what # the server is at.
Since you got banned while using 310 ms delay, try increasing it. 100x310 is 31 seconds, so it's quite close to the limit.
EDIT: you can test out the buffer with echo commands.
//addbuf echo -a line | addbuf echo -a line another line | addbuf echo -a line third line | addbuf echo -a line and so on