Trunk selection by round

Its not mine idea but i think it can be useful if youll add this possibility for the usual users:

This script give`s the possibility to chose trunks not from 1 - n, but doing it by ROUND.
That can help to divide the load on all trunks, but not only on the first one and go on…

Here is code. It was made by cron333 from asterisk-support.ru

exten => _X.,n,Set(GATE=${RAND(1|2)})
exten => _X.,n,Set(COUNT=2)
exten => _X.,n,Set(RET=1)
exten => X.,n,Goto(m9${GATE})
;
exten => _X.,n(m9_1),GotoIf($["${RET}" > “${COUNT}”]?hangup)
exten => _X.,n,Set(RET=$[${RET} + 1])
exten => _X.,n,Dial(SIP/peer1/${EXTEN})
;
exten => _X.,n(m9_2),GotoIf($["${RET}" > “${COUNT}”]?hangup)
exten => _X.,n,Set(RET=$[${RET} + 1])
exten => _X.,n,Dial(SIP/peer2/${EXTEN})
;
exten => _X.,n,GotoIf($["${RET}" > “${COUNT}”]?hangup)
exten => _X.,n,Goto(m9_1)
;
exten => _X.,n(hangup),Hangup

I think it can be a good idea to improve it and add to FreePBX web service.