OnDialogResponse not working
#1

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;
}
Reply
#2

Hmmm try this

instead of "if(dialogid == teleport)
Do this

pawn Код:
switch(dialogid)
case DIALOG_TELEPORT: {
blablabla
}
Reply
#3

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.
Reply
#4

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 
Reply
#5

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;
}
Reply
#6

Sorry, nothing happens.
Reply
#7

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.
Reply
#8

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.
Reply
#9

The code works, refer to what Konstantinos said. You're probably using a dialog in your script that already has ID 1.
Reply
#10

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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)