OnDialogResponse not working -
alibalicharlton - 03.07.2014
I'm new to pawn scripting, and I've put together this menu to combine my teleporting positions. The menu appears but when I choose something nothing happens. I've taken working code from other similar mods and my code still doesn't work. It's probably something simple, can anyone see what I've done wrong?
My code:
Код:
#include <a_samp>
#define DIALOG_TELEPORT 1
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tel", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,DIALOG_TELEPORT,DIALOG_STYLE_LIST ,"Teleporter","LS Airport\nTall Building","Teleport","Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TELEPORT)
{
if(response)
{
switch(listitem)
{
case 0: SetPlayerPos(playerid,1861.1454,-2491.4324,13.5547);
case 1: SetPlayerPos(playerid,1545.4745,-1362.4923,329.4586);
}
}
return 1;
}
return 0;
}
Re: OnDialogResponse not working -
EmilLykke - 03.07.2014
Hmmm try this
instead of "if(dialogid == teleport)
Do this
pawn Код:
switch(dialogid)
case DIALOG_TELEPORT: {
blablabla
}
Re: OnDialogResponse not working -
alibalicharlton - 03.07.2014
Quote:
Originally Posted by EmilLykke
Hmmm try this
instead of "if(dialogid == teleport)
Do this
pawn Код:
switch(dialogid) case DIALOG_TELEPORT: { blablabla }
|
Sorry, no joy.
Re: OnDialogResponse not working -
Timeless - 03.07.2014
hmm try this
PHP код:
switch(dialogid)
{
case *your dialog definition*
{
if response // if the player chooses the first case for instantce "lv"
{
//SetPlayerPos //bla bla bla
Re: OnDialogResponse not working -
Dignity - 03.07.2014
Why do you guys recommend him to use switch while the if(dialogid == x) is correct aswell? The issue doesn't happen because of that.
This works, has been tested by me:
pawn Код:
#include <a_samp>
#define DIALOG_TELEPORT 1
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/tel", cmdtext, true, 10) == 0)
{
ShowPlayerDialog(playerid,DIALOG_TELEPORT,DIALOG_STYLE_LIST ,"Teleporter","LS Airport\nTall Building","Teleport","Cancel");
return 1;
}
return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == DIALOG_TELEPORT)
{
if(response)
{
switch(listitem)
{
case 0: return SetPlayerPos(playerid,1861.1454,-2491.4324,13.5547);
case 1: return SetPlayerPos(playerid,1545.4745,-1362.4923,329.4586);
}
}
return 1;
}
return 0;
}
Re: OnDialogResponse not working -
alibalicharlton - 03.07.2014
Sorry, nothing happens.
Re: OnDialogResponse not working -
Konstantinos - 03.07.2014
Two things:
- Return 0 at the end of OnDialogResponse to any script the server is running (like you do in the above) so it will allow searching to the other script if the dialog was not found in the current one.
- Change the dialogid to some other number because it may confict. Use for example 321.
Re: OnDialogResponse not working -
alibalicharlton - 03.07.2014
Quote:
Originally Posted by Mionee
Why do you guys recommend him to use switch while the if(dialogid == x) is correct aswell? The issue doesn't happen because of that.
This works, has been tested by me:
pawn Код:
#include <a_samp>
#define DIALOG_TELEPORT 1
public OnPlayerCommandText(playerid, cmdtext[]) { if (strcmp("/tel", cmdtext, true, 10) == 0) { ShowPlayerDialog(playerid,DIALOG_TELEPORT,DIALOG_STYLE_LIST ,"Teleporter","LS Airport\nTall Building","Teleport","Cancel");
return 1; }
return 0; }
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) { if(dialogid == DIALOG_TELEPORT) { if(response) { switch(listitem) { case 0: return SetPlayerPos(playerid,1861.1454,-2491.4324,13.5547); case 1: return SetPlayerPos(playerid,1545.4745,-1362.4923,329.4586); } }
return 1; }
return 0; }
|
Thanks, but it didn't work either, I copied your code straight into pawn but same result. I can't think what it is as other mods I've downloaded work fine with menu's.
Re: OnDialogResponse not working -
Dignity - 03.07.2014
The code works, refer to what Konstantinos said. You're probably using a dialog in your script that already has ID 1.
Re: OnDialogResponse not working -
alibalicharlton - 03.07.2014
Quote:
Originally Posted by Konstantinos
Two things:
- Return 0 at the end of OnDialogResponse to any script the server is running (like you do in the above) so it will allow searching to the other script if the dialog was not found in the current one.
- Change the dialogid to some other number because it may confict. Use for example 321.
|
I tried a couple of random numbers, but nothing changed, any ideas?