Code executing two times
#1

Hi.

Do you know why this code is executing twice?

pawn Код:
#define Dialog(%1) forward DialogResponse_%1(playerid,response,listitem,inputtext[]); \
                   public DialogResponse_%1(playerid,response,listitem,inputtext[])


public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    new DialogToCall[24];
        if(dialogid >= 0)
    format(DialogToCall,24,"DialogResponse_%d",dialogid);
        if(isnull(inputtext))format(inputtext,2,"\1");
        if(funcidx(DialogToCall) != -1)
    return CallLocalFunction(DialogToCall,"iiis",playerid,response,listitem,inputtext);
       
        return 0;
}
if I use it:

pawn Код:
Dialog(1)
{
  if(response)
  {
       if(IsNumeric(inputtext))
       {
                     new deposit = strval(inputtext);
             new asd[10];
             format(asd,sizeof(asd),"%i",deposit);
             SendClientMessage(playerid,COLOR_YELLOW,asd);
        }

  return 1;
}
That will print two times the number 1, but I only press the button once.

The ShowPlayerDialog function is as always:

ShowPlayerDialog(playerid,1,DIALOG_STYLE_INPUT,"We lcome","Input something","Hit it","Cancel");
Reply
#2

I've found that the DialogToCall should be outside the Callback and not inside... I don't know why.
Reply


Forum Jump:


Users browsing this thread: