Not more than 2 incomming calls

Hi everyone.

I’ve tried to write a script for a call limitation for a telephone.

Now I have the problem when the call is answered asterisk see that as hangup and calculate -1.

Why is that a hangup for asterisk or is there another way?

PS: I have the “telefon” context because in “ankommen” are more than one number and I need the calculation only for one number.

[code]context ankommend{
493033XXXXX =>{
Dial(Local/200@telefon);
}

493035XXXXXX =>{
Dial(SIP/1003,80);
}
}

context spaeter{
100 =>{
Wait(22);
Dial(SIP/1001,98);
}
101 =>{
Wait(35);
Dial(SIP/1002,85);
}
}

context telefon{
200 => {
if ("${DB(stat/Gespraeche)}" < “2”){
Set(DB(stat/Gespraeche)=${MATH(${DB(stat/Gespraeche)}+1,int)});
Wait(3);
Answer();
Playback(/var/lib/asterisk/willkommen);
Dial(Local/100@spaeter,120,m(music));
Playback(/var/lib/asterisk/ende);
Hangup();
}
else{
Set(DB(stat/Gespraeche)=${MATH(${DB(stat/Gespraeche)}+1,int)});
Ringing();
Wait(3);
Answer();
Playback(/var/lib/asterisk/belegt);
Hangup();
}
}
h => {
Set(DB(stat/Gespraeche)=${MATH(${DB(stat/Gespraeche)}-1,int)});
}
}[/code]

put the phones on an special context and use GROUP_COUNT() function