Code executing two times - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Code executing two times (
/showthread.php?tid=267210)
Code executing two times -
clavador - 07.07.2011
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");
Respuesta: Code executing two times -
clavador - 07.07.2011
I've found that the DialogToCall should be outside the Callback and not inside... I don't know why.