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;
}
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;
}
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));
}
if(!strcmp(inputtext, "sd", false)) // it means that if I type sd something will happen
Originally Posted by ViruZZzZ_ChiLLL
Put that under response
pawn Code:
|
if(dialogid == NAME_COLOR3 && response)
{
if(!strcmp(inputtext, "sd", false))
{
tmp = strtok( inputtext, idx );
strval( strtok( inputtext, idx ) );
SetPlayerColor(playerid,strval(tmp));
}
}
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.
}
}
Originally Posted by LTomi
pawn Code:
|
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
|
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;
}
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);
}
}
}
Originally Posted by ♣ Joker ♠
pawn Код:
|