Showing a certain dialog after responding to a dialog
#1

I have a dialog and I would like it to show something different on each rank.

That thing will be put under OnDialogResponse, but is it correct if I use it this way?
pawn Код:
if(dialogid == SOME_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                if(Rank 1)
                {
                    ShowPlayerDialog( etc. etc....);
                }
                else if(Rank 2)
                {
                    ShowPlayerDialog( etc. etc....);
                }
            }
        }
        return 1;
    }
Reply
#2

No its not
its like this -
pawn Код:
if(dialogid == SOME_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0://Note the change in this line || listitem starts from 0 || that is if they clicked 1st item of list
                {
                    ShowPlayerDialog( etc. etc....);
                }
                case 1://Note the change in this line
                {
                    ShowPlayerDialog( etc. etc....);
                }
            }
        }
        return 1;
    }
You can read about switch-case on ******
Reply
#3

Quote:
Originally Posted by BroZeus
Посмотреть сообщение
No its not
its like this -
pawn Код:
if(dialogid == SOME_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0://Note the change in this line || listitem starts from 0 || that is if they clicked 1st item of list
                {
                    ShowPlayerDialog( etc. etc....);
                }
                case 1://Note the change in this line
                {
                    ShowPlayerDialog( etc. etc....);
                }
            }
        }
        return 1;
    }
You can read about switch-case on ******
I think I wrongly forget to write the switch cases, I want it to be like
pawn Код:
case 0:
{
    if(rank 1)
    {
        ShowPlayerDialog(etc....)
    }
    else if(rank 2)
    {
        ShowPlayerDialog(etc....)
    }
That's what I meant, I just forget to put the the switch cases.
Reply
#4

Quote:
Originally Posted by dionisak0s
Посмотреть сообщение
I think I wrongly forget to write the switch cases, I want it to be like
pawn Код:
case 0:
{
    if(rank 1)
    {
        ShowPlayerDialog(etc....)
    }
    else if(rank 2)
    {
        ShowPlayerDialog(etc....)
    }
That's what I meant, I just forget to put the the switch cases.
That wouldn't work anyway, you need to use your predefined enumerators/variables that you're using to store ranks, example:

pawn Код:
switch(dialogid) // this is not necessary, but I use it sometimes
{
    case SOME_DIALOG:
    {
        if(!response) return 1; // if there is no response (esc or button 2), dialog stops here
        switch(listitem) // switching through the items on the dialog
        {
            case 0: // first item on the dialog is here
            {
                if(/*variable here, example:*/pRank[playerid] == 1) // notice that "Rank 1" will just return the error of undefined symbol 'Rank' and expected zero or something along those lines
                {
                    ShowPlayerDialog(etc. etc. etc.);
                }
                else if(/*variable here, example:*/pRank[playerid] == 2) // as above
                {
                    ShowPlayerDialog(etc. etc. etc.);
                }
            }
        }
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by DanishHaq
Посмотреть сообщение
That wouldn't work anyway, you need to use your predefined enumerators/variables that you're using to store ranks, example:

pawn Код:
switch(dialogid) // this is not necessary, but I use it sometimes
{
    case SOME_DIALOG:
    {
        if(!response) return 1; // if there is no response (esc or button 2), dialog stops here
        switch(listitem) // switching through the items on the dialog
        {
            case 0: // first item on the dialog is here
            {
                if(/*variable here, example:*/pRank[playerid] == 1) // notice that "Rank 1" will just return the error of undefined symbol 'Rank' and expected zero or something along those lines
                {
                    ShowPlayerDialog(etc. etc. etc.);
                }
                else if(/*variable here, example:*/pRank[playerid] == 2) // as above
                {
                    ShowPlayerDialog(etc. etc. etc.);
                }
            }
        }
    }
    return 1;
}
I already know that, I just gave an example with ranks.
I want let's say the last dialog to be shown for R3 and above I have to make it Rank >= 4? (As I said it's just an example
Reply
#6

Nevermind, I got it; I just did it like this:

pawn Код:
if(dialogid == SOME_DIALOG)
    {
        if(response)
        {
            switch(listitem)
            {
                case 0:
                {
                    if(PlayerInfo[playerid][pRank] == 1)
                    {
                        ShowPlayerDialog(...)
                    }
                    else if(PlayerInfo[playerid][pRank] == 2)
                    {
                        ShowPlayerDialog(...)
                    }
                    else if(PlayerInfo[playerid][pRank] == 3)
                    {
                        ShowPlayerDialog(...)
                    }
                    else if(PlayerInfo[playerid][pRank] >= 4)
                    {
                        ShowPlayerDialog(...)
                    }
                }
            }
            return 1;
        }
    }
Edit 2: I forget that if I post once again a reply it is going to make a new one, my bad. By the way whoever helped me receives a rep as a thanks.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)