Dialog problem
#1

Hey,i have a problem(again o.O),this time with dialogs.
I'm embarrassed to ask it,but here
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
 
    if(dialogid == 1 && response)
    switch(listitem)
    {
      case 0:
      {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose from list:", "Red\nBlue\nLight blue\nGreen\nLight Green\nYellow\nLight yellow\nBlack\nWhite\nOrange\nBrown", "Apply", "Cancel");
      }
      case 1:
      {
        ShowPlayerDialog(playerid, 3,DIALOG_STYLE_INPUT,"Write color"," Write a color in hex notation format:","Apply","Cancel");
      }
    }
    if(dialogid == 2 && response)
    switch(listitem)
    {
      case 0:
      {
        SetPlayerColor(playerid,COLOR_RED);
            }
            case 1:
            {
              SetPlayerColor(playerid,COLOR_BLUE);
            }
            case 2:
            {
            SetPlayerColor(playerid,COLOR_LIGHTBLUE);
            }
            case 3:
      {
        SetPlayerColor(playerid,COLOR_GREEN);
            }
            case 4:
            {
              SetPlayerColor(playerid,COLOR_LIGHTGREEN);
            }
            case 5:
            {
              SetPlayerColor(playerid,COLOR_YELLOW);
            }
            case 6:
      {
        SetPlayerColor(playerid,COLOR_LIGHTYELLOW);
            }
            case 7:
            {
              SetPlayerColor(playerid,COLOR_BLACK);
            }
            case 8:
            {
              SetPlayerColor(playerid,COLOR_WHITE);
            }
            case 9:
      {
        SetPlayerColor(playerid,COLOR_ORANGE);
            }
            case 10:
            {
              SetPlayerColor(playerid,COLOR_BROWN);
            }
        }
        if(dialogid == 3 && response)
        {
          new tmp[128];
            if(response)
            {
              if(strval(tmp) < 10 || strval(tmp) > 10)
                {
                  SendClientMessage(playerid,COLOR_RED,"ERROR: Invailed color format.");
                }
                else
                {
                SetPlayerColor(playerid,strval(tmp));
              }
            }
        }
    return 1;
}
The problem is,when i choose one of the options from dialog id 1,it doesn't show dialog id 2 or 3.
E.X if i chose "Choose from list" it doesn't affect.
Probably something stupid I've done.
Anyway thanks in advance to all helpers.
Reply
#2

Uhmmm... Try this :P
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{

    if(dialogid == 1 && response)
    {
    switch(listitem)
    {
      case 0:
      {
        ShowPlayerDialog(playerid, 2, DIALOG_STYLE_LIST, "Choose from list:", "Red\nBlue\nLight blue\nGreen\nLight Green\nYellow\nLight yellow\nBlack\nWhite\nOrange\nBrown", "Apply", "Cancel");
      }
      case 1:
      {
        ShowPlayerDialog(playerid, 3,DIALOG_STYLE_INPUT,"Write color"," Write a color in hex notation format:","Apply","Cancel");
      }
    }
    }
    if(dialogid == 2 && response)
    {
    switch(listitem)
    {
      case 0:
      {
        SetPlayerColor(playerid,COLOR_RED);
            }
            case 1:
            {
              SetPlayerColor(playerid,COLOR_BLUE);
            }
            case 2:
            {
            SetPlayerColor(playerid,COLOR_LIGHTBLUE);
            }
            case 3:
      {
        SetPlayerColor(playerid,COLOR_GREEN);
            }
            case 4:
            {
              SetPlayerColor(playerid,COLOR_LIGHTGREEN);
            }
            case 5:
            {
              SetPlayerColor(playerid,COLOR_YELLOW);
            }
            case 6:
      {
        SetPlayerColor(playerid,COLOR_LIGHTYELLOW);
            }
            case 7:
            {
              SetPlayerColor(playerid,COLOR_BLACK);
            }
            case 8:
            {
              SetPlayerColor(playerid,COLOR_WHITE);
            }
            case 9:
      {
        SetPlayerColor(playerid,COLOR_ORANGE);
            }
            case 10:
            {
              SetPlayerColor(playerid,COLOR_BROWN);
            }
        }
        }
        if(dialogid == 3 && response)
        {
          new tmp[128];
            if(response)
            {
              if(strval(tmp) < 10 || strval(tmp) > 10)
                {
                  SendClientMessage(playerid,COLOR_RED,"ERROR: Invailed color format.");
                }
                else
                {
                SetPlayerColor(playerid,strval(tmp));
              }
            }
        }
    return 1;
}
Reply
#3

Sorry for the late reply I went to my cousins yesterday and I only came back now,
anyway It's still not working D:
Thanks for trying though. :P
Anyone else please?

EDIT:
I've moved it from my FS to my GM,It's working now o.O
Anyway I got a new problem,here:
pawn Code:
new res[256];
        new idx;
        new tmp[256];
        res = strtok(inputtext, idx);
        if(dialogid == NAME_COLOR3 && response)
        {
        tmp = strtok( inputtext, idx );
        strval( strtok( inputtext, idx ) );
        SetPlayerColor(playerid,strval(tmp));
        }
The problem is that it doesn't matter what i write in the input box it sets my color to black.
What's wrong?
Reply
#4

Put that under response

pawn Code:
if(!strcmp(inputtext, "sd", false)) // it means that if I type sd something will happen
Reply
#5

Quote:
Originally Posted by ViruZZzZ_ChiLLL
Put that under response

pawn Code:
if(!strcmp(inputtext, "sd", false)) // it means that if I type sd something will happen
Ermm,like that?
pawn Code:
if(dialogid == NAME_COLOR3 && response)
        {
          if(!strcmp(inputtext, "sd", false))
          {
                tmp = strtok( inputtext, idx );
        strval( strtok( inputtext, idx ) );
                SetPlayerColor(playerid,strval(tmp));
            }
        }
Because that one didn't work xD
Reply
#6

pawn Code:
if(dialogid == NAME_COLOR3)
{
   if(response == 1) // Player has chosen the left button.
   {
     if(!strlen(inputtext))
     {
        SendClientMessage(playerid, COLOR_RED, "You left the input field blank.");
        ShowPlayerDialog(playerid, NAME_COLOR3, DIALOG_STYLE_INPUT, ... ); // Basically the dialog dissappears, so we show it again to let the player write the color ID in and send it again.
     }
     else
     {
        // You can use the IsNumeric function here to check if the inputtext is a number or not.
        SetPlayerColor(playerid,strval(inputtext));
     }
   }
   else // Player has chosen the right button.
   {
     // Do something here.
   }
}
EDIT: I've improved the code a bit.
Reply
#7

Quote:
Originally Posted by LTomi
pawn Code:
if(dialogid == NAME_COLOR3)
{
   if(response == 1) // Player has chosen the left button.
   {
     if(!strlen(inputtext))
     {
        SendClientMessage(playerid, COLOR_RED, "You left the input field blank.");
        ShowPlayerDialog(playerid, NAME_COLOR3, DIALOG_STYLE_INPUT, ... ); // Basically the dialog dissappears, so we show it again to let the player write the color ID in and send it again.
     }
     else
     {
        // You can use the IsNumeric function here to check if the inputtext is a number or not.
        SetPlayerColor(playerid,strval(inputtext));
     }
   }
   else // Player has chosen the right button.
   {
     // Do something here.
   }
}
EDIT: I've improved the code a bit.
Thanks for the tries dude but It's still setting my color to black o.O
Reply
#8

after alittle testing, each dialog ID has to return a value. so just put return 1;} at the end of each
Reply
#9

Quote:
Originally Posted by _Ч§hмf†ҐЧ™_
after alittle testing, each dialog ID has to return a value. so just put return 1;} at the end of each
Hmm,
like this? :
pawn Code:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == NAME_COLOR1 && response)
    {
    switch(listitem)
    {
      case 0:
      {
        ShowPlayerDialog(playerid, NAME_COLOR2, DIALOG_STYLE_LIST, "Choose from list:", "Red\nBlue\nLight blue\nGreen\nLight Green\nYellow\nLight yellow\nBlack\nWhite\nOrange\nBrown", "Apply", "Cancel");
      }
      case 1:
      {
        ShowPlayerDialog(playerid, NAME_COLOR3,DIALOG_STYLE_INPUT,"Write color"," Write a color in hex notation format:","Apply","Cancel");
      }
    }
    }
    if(dialogid == NAME_COLOR2 && response)
    {
    switch(listitem)
    {
      case 0:
      {
        SetPlayerColor(playerid,COLOR_RED);
            }
            case 1:
            {
              SetPlayerColor(playerid,COLOR_BLUE);
            }
            case 2:
            {
            SetPlayerColor(playerid,COLOR_LIGHTBLUE);
            }
            case 3:
      {
        SetPlayerColor(playerid,COLOR_GREEN);
            }
            case 4:
            {
              SetPlayerColor(playerid,COLOR_LIGHTGREEN);
            }
            case 5:
            {
              SetPlayerColor(playerid,COLOR_YELLOW);
            }
            case 6:
      {
        SetPlayerColor(playerid,COLOR_LIGHTYELLOW);
            }
            case 7:
            {
              SetPlayerColor(playerid,COLOR_BLACK);
            }
            case 8:
            {
              SetPlayerColor(playerid,COLOR_WHITE);
            }
            case 9:
      {
        SetPlayerColor(playerid,COLOR_ORANGE);
            }
            case 10:
            {
              SetPlayerColor(playerid,COLOR_BROWN);
            }
        }
        return 1;}
        if(dialogid == NAME_COLOR3)
        {
        if(response == 1)
        {
            if(!strlen(inputtext))
            {
                SendClientMessage(playerid, COLOR_RED, "You left the input field blank.");
                ShowPlayerDialog(playerid, NAME_COLOR3,DIALOG_STYLE_INPUT,"Write color"," Write a color in hex notation format:","Apply","Cancel");
            }
            else
            {
                SetPlayerColor(playerid,strval(inputtext));
            }
        }
        else
        {
        ShowPlayerDialog(playerid, NAME_COLOR1, DIALOG_STYLE_LIST, "Name colors dialog", "Choose from a list\nWrite your own color(!)", "Apply", "Cancel");
        }
            return 1;}
        return 1;
}
It didn't work
Reply
#10

Bump D:
Reply
#11

pawn Код:
if(dialogid == NAME_COLOR3)
    {
        if(response == 1)
        {
            if(inputtext[0] == EOS)
            {
                SendClientMessage(playerid, COLOR_RED, "You left the input field blank.");
                return ShowPlayerDialog(playerid, NAME_COLOR3, DIALOG_STYLE_INPUT, "Write color", " Write a color in hex notation format:", "Apply", "Cancel");
            }
            new c;
            for( ; inputtext[c]; c++)
                if(('A' <= inputtext[c] && inputtext[c] <= 'F' && '0' <= inputtext[c] && inputtext[c] <= '9') == false)
                    break;
            if(inputtext[c] != EOS)
                return SendClientMessage(playerid, COLOR_RED, "Invalid character (Hex notation 0 - 9, A - F)");
            if(c != 9)
                return SendClientMessage(playerid, COLOR_RED, "Invalid format (Example: CCAA8866 [Red/Green/Blue/Visibility])");
            new color, Float:h;
            for(c--; c != -1; c--, h++)
                if(inputtext[c] >= 'A')
                    color += ((inputtext[c] - 'A' + 10) * floatpower(16.0, h));
                else    color += ((inputtext[c] - '0') * floatpower(16.0, h));
            return SetPlayerColor(playerid, color);
        }
    }
}
Reply
#12

Quote:
Originally Posted by ♣ Joker ♠
pawn Код:
if(dialogid == NAME_COLOR3)
    {
        if(response == 1)
        {
            if(inputtext[0] == EOS)
            {
                SendClientMessage(playerid, COLOR_RED, "You left the input field blank.");
                return ShowPlayerDialog(playerid, NAME_COLOR3, DIALOG_STYLE_INPUT, "Write color", " Write a color in hex notation format:", "Apply", "Cancel");
            }
            new c;
            for( ; inputtext[c]; c++)
                if(('A' <= inputtext[c] && inputtext[c] <= 'F' && '0' <= inputtext[c] && inputtext[c] <= '9') == false)
                    break;
            if(inputtext[c] != EOS)
                return SendClientMessage(playerid, COLOR_RED, "Invalid character (Hex notation 0 - 9, A - F)");
            if(c != 9)
                return SendClientMessage(playerid, COLOR_RED, "Invalid format (Example: CCAA8866 [Red/Green/Blue/Visibility])");
            new color, Float:h;
            for(c--; c != -1; c--, h++)
                if(inputtext[c] >= 'A')
                    color += ((inputtext[c] - 'A' + 10) * floatpower(16.0, h));
                else    color += ((inputtext[c] - '0') * floatpower(16.0, h));
            return SetPlayerColor(playerid, color);
        }
    }
}
WOW! Much more complicated than i thought.
Thanks!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)