Dynamic extension based on call

hi :
how can i make playback option for incoming calls to be played dynamically for each call,each call will directed to another sound file and not always the same file ,and that will be based on each call to go to sepecific extension ,i thought of “Gotoif” but there is no specific condition to use , i will give an example :
first call will go and playback sound file named by play1.gsm
2nd call will go and playback sound file named by play2.gsm
3rd call will go and playback sound file named by play3.gsm
and when call count reaches to 3rd call it will reset and back again to first stage , can any one help me ,what functions i should use to get this job done ,thanks .

Use a random number, but then you could use that as part of the file name.

can you explain more.

https://wiki.asterisk.org/wiki/display/AST/Function_RAND

Use the AstDB.
exten => s,1,NoOP()
same => n,ExecIf($[${DB(counters/counter1)} > 3]?Set(DB(counters/counter1)=1))
same => n,Playback(play${DB(counters/counter1)})
same => n,Set(DB(counters/counter1)=${MATH(${DB(counters/counter1)}+1,int)})
same => n,Hangup()

thanks for your reply