Skin selection via inputtext? -
rangerxxll - 01.03.2014
It doesn't open the input dialog. What's the issue?
pawn Код:
if(dialogid == SHOP_DIALOG)
{
switch(dialogid)
{
case 0:
{
ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
}
}
}
if(dialogid == SHOP_SKIN)
{
new skin = strval(inputtext);
SetPlayerSkin(playerid, skin);
GivePlayerMoney(playerid, -5000);
}
Re: Skin selection via inputtext? -
Konstantinos - 01.03.2014
Your code checks if the dialogid is equal to SHOP_DIALOG and then you use switch on dialogid and you say, if the dialogid is 0 then show the dialog SHOP_SKIN.
I guess you mean list item:
pawn Код:
if (dialogid == SHOP_DIALOG)
{
if (response)
{
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
}
return 1;
}
else if (dialogid == SHOP_SKIN)
{
if (response)
{
SetPlayerSkin(playerid, strval(inputtext));
GivePlayerMoney(playerid, -5000);
}
return 1;
}
However, using switch is faster and it's recommended:
pawn Код:
switch (dialogid)
{
case SHOP_DIALOG:
{
if (response)
{
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
}
return 1;
}
case SHOP_SKIN:
{
if (response)
{
SetPlayerSkin(playerid, strval(inputtext));
GivePlayerMoney(playerid, -5000);
}
return 1;
}
}
If you don't use DIALOG_STYLE_LIST in SHOP_DIALOG dialog, then listitem will be -1 so you will need to change:
pawn Код:
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
to:
pawn Код:
ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
Re: Skin selection via inputtext? -
rangerxxll - 01.03.2014
I don't understand what you mean. Could you explain? Why wouldn't you add a switch to switch through the dialog ID's? And why is
pawn Код:
if (!listitem) ShowPlayerDialog
needed?
Re: Skin selection via inputtext? -
Konstantinos - 01.03.2014
You already check the dialogid if it's equal with SHOP_DIALOG so you don't have to check if the dialogid is equal to 0 (using switch) when you already know that dialogid is equal to SHOP_DIALOG.
I was editing the post while you posted, but I don't know how you've used the dialog yet so read this one:
Quote:
Originally Posted by Konstantinos
If you don't use DIALOG_STYLE_LIST in SHOP_DIALOG dialog, then listitem will be -1 so you will need to change:
pawn Код:
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
to:
pawn Код:
ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
|
Re: Skin selection via inputtext? -
rangerxxll - 01.03.2014
Then for any other list item (without a input.) would it just be simply
pawn Код:
if(dialogid == whatever.)
?
Re: Skin selection via inputtext? -
Konstantinos - 01.03.2014
No, dialogid and listitem are totally different.
Dialogid is the number of the dialog you display to a player.
Listitem is the item (line) of the dialog when DIALOG_STYLE_LIST has been used. When the style is different such as an input, listitem will be -1.
Re: Skin selection via inputtext? -
rangerxxll - 01.03.2014
Well, either way it's still not opening the input dialog.
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
switch (dialogid)
{
case SHOP_DIALOG:
{
if (response)
{
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
}
return 1;
}
case SHOP_SKIN:
{
if (response)
{
SetPlayerSkin(playerid, strval(inputtext));
GivePlayerMoney(playerid, -5000);
}
return 1;
}
}
return 0;
}
I did it before without the !listitem. Just forgot how. :3
Re: Skin selection via inputtext? -
Konstantinos - 01.03.2014
Like I said, if you use input style in SHOP_DIALOG, then use:
pawn Код:
case SHOP_DIALOG:
{
if (response) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
return 1;
}
if you use list style in SHOP_DIALOG and the first item on the list is shop skin, then use:
pawn Код:
case SHOP_DIALOG:
{
if (response)
{
if (!listitem) ShowPlayerDialog(playerid, SHOP_SKIN, DIALOG_STYLE_INPUT, "Enter a valid Skin ID.", "", "OK", "Cancel");
}
return 1;
}
If you don't know what style it uses, post the line you show the dialog SHOP_DIALOG.