02.02.2014, 18:28
I suggest you try "return 0;" and "return 1;" in OnDialogResponse in your filterscript (as stated in your server.cfg file) and try to process a dialog that's processed in the second filterscript or your gamemode.
Filterscript 1:
Gamemode:
Now execute the ShowPlayerDialog in your gamemode and click the OK button.
You'll see that your server console will print "You've clicked the OK button".
Change the "return 0;" to "return 1;" in your filterscript and execute the ShowPlayerDialog again.
When you click on the OK button now, you'll NOT see the message appear in your server console.
You'll think your gamemode has errors/bugs, but the fault lies within your filterscript.
Why?
When you process a dialog's responses in your server, the server will first look for the dialogid "1" in your filterscripts.
It doesn't find it there as there is no code to process it.
But it finds "return 1;" in there and the server now thinks you've processed the dialog in your filterscript.
The server won't proceed to your other filterscripts and gamemode as returning 1 in OnDialogResponse actually means that the dialog has been processed and won't look any further.
Now, if you put "return 0;" again in your filterscript, it's working again for that dialog in your gamemode.
Returning 0 means that dialogid "1" isn't processed in your filterscript, and the server will call the callback in your other filterscripts and finally in your gamemode.
After seeing "return 0;" in your filterscript (and there are no other filterscripts in this example), the server will move on to your gamemode and call OnDialogResponse there.
In your gamemode, it finds dialogid 1, processes it and prints the message properly.
In short:
"return 1;" -> stop processing OnDialogResponse (don't move on to the next script)
"return 0;" -> go to the next script and call OnDialogResponse
Some other callbacks have different meanings for "return 0;" and "return 1;".
As stated above, OnPlayerText works the other way around:
"return 1;" -> go to the next script and call OnPlayerText
"return 0;" -> stop processing OnPlayerText (don't move on to the next script)
In the gamemode however, you can return anything you want in that callback, as the gamemode is the last script in line to be processed anyway. So it doesn't matter if you allow the server to look further, as there are no other scripts to call after the gamemode.
Filterscript 1:
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 0;
}
pawn Код:
//Somewhere in your code:
ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Title:", "Option 1\nOption 2", "OK", "");
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case 1: if (response == 1) printf("You've clicked the OK button");
}
return 1;
}
You'll see that your server console will print "You've clicked the OK button".
Change the "return 0;" to "return 1;" in your filterscript and execute the ShowPlayerDialog again.
When you click on the OK button now, you'll NOT see the message appear in your server console.
You'll think your gamemode has errors/bugs, but the fault lies within your filterscript.
Why?
When you process a dialog's responses in your server, the server will first look for the dialogid "1" in your filterscripts.
It doesn't find it there as there is no code to process it.
But it finds "return 1;" in there and the server now thinks you've processed the dialog in your filterscript.
The server won't proceed to your other filterscripts and gamemode as returning 1 in OnDialogResponse actually means that the dialog has been processed and won't look any further.
Now, if you put "return 0;" again in your filterscript, it's working again for that dialog in your gamemode.
Returning 0 means that dialogid "1" isn't processed in your filterscript, and the server will call the callback in your other filterscripts and finally in your gamemode.
After seeing "return 0;" in your filterscript (and there are no other filterscripts in this example), the server will move on to your gamemode and call OnDialogResponse there.
In your gamemode, it finds dialogid 1, processes it and prints the message properly.
In short:
"return 1;" -> stop processing OnDialogResponse (don't move on to the next script)
"return 0;" -> go to the next script and call OnDialogResponse
Some other callbacks have different meanings for "return 0;" and "return 1;".
As stated above, OnPlayerText works the other way around:
"return 1;" -> go to the next script and call OnPlayerText
"return 0;" -> stop processing OnPlayerText (don't move on to the next script)
In the gamemode however, you can return anything you want in that callback, as the gamemode is the last script in line to be processed anyway. So it doesn't matter if you allow the server to look further, as there are no other scripts to call after the gamemode.