dialog gender input -
v4yne1 - 15.03.2019
how to get dialog_style_input's input and check if it's one of the genders
Код:
if(dialogid == DIALOG_GENDER)
{
if(!response)
{
Kick(playerid);
}
else
{
if(strlen(inputtext))
{
new gender = inputtext;
if(gender != "male" || gender != "female")
{
ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Gender","What is the gender of your character? (male/female)","Next","Quit");
}
else
{
PlayerInfo[playerid][Gender] = gender;
new string[64];
format(string, sizeof(string), "You are %s", gender);
SendClientMessage(playerid, -1, string);
}
}
}
}
error 033: array must be indexed (variable "-unknown-")
error 001: expected token: "-string end-", but found "-identifier-"
Код:
new gender = inputtext;
if(gender != "male" || gender != "female")
Re: dialog gender input -
TheToretto - 15.03.2019
You can't compare strings like that. Use
strcmp (cmp stands for compare)
pawn Код:
if(!strcmp(gender, "male") || !strcmp(gender, "female"))
// this means gender is equal to either male or female, remove the "!" to do the opposite
Re: dialog gender input -
v4yne1 - 15.03.2019
Quote:
Originally Posted by TheToretto
You can't compare strings like that. Use strcmp (cmp stands for compare)
pawn Код:
if(!strcmp(gender, "male") || !strcmp(gender, "female")) // this means gender is equal to either male or female, remove the "!" to do the opposite
|
thanks,
how do I get dialog's inputtext and put it under 'gender' variable?
Код:
new gender = inputtext;
i get: error 033: array must be indexed (variable "-unknown-")
error 001: expected token: "-string end-", but found "-identifier-"
Re: dialog gender input -
TheToretto - 15.03.2019
Strings should be arrays so each character is stored in a cell. To get user's input use
sscanf
Quote:
Originally Posted by v4yne1
thanks,
how do I get dialog's inputtext and put it under 'gender' variable?
Код:
new gender = inputtext;
i get: error 033: array must be indexed (variable "-unknown-")
error 001: expected token: "-string end-", but found "-identifier-"
|
pawn Код:
if(dialogid == DIALOG_GENDER)
{
if(!response)
{
Kick(playerid);
}
else
{
if(strlen(inputtext))
{
new gender[8];
if(sscanf(inputtext, "s[7]", gender))
return 0; // The user's input is not a string, so it stops the code.
if(strcmp(gender, "male") || strcmp(gender, "female")) // if the code doesn't stop, it will reach here and execute
{
ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Gender","What is the gender of your character? (male/female)","Next","Quit");
}
else
{
strcat(PlayerInfo[playerid][Gender], gender, 8); // Dont copy strings directly, use strcat.
new string[16];
format(string, sizeof(string), "You are %s", gender);
SendClientMessage(playerid, -1, string);
}
}
}
}
Re: dialog gender input -
v4yne1 - 15.03.2019
now when I type anything it puts it as my gender
for example
i type 'a' it sends me a message my gender is 'a'
id like to make male and female only valid answers(genders)
Re: dialog gender input -
TheToretto - 15.03.2019
Quote:
Originally Posted by v4yne1
now when I type anything it puts it as my gender
for example
i type 'a' it sends me a message my gender is 'a'
id like to make male and female only valid answers(genders)
|
Try again, I updated the code.
Re: dialog gender input -
v4yne1 - 15.03.2019
doesn't work.
nothing works, only when i leave it blank and press enter. then the dialog just closes. but other answers dont work at all. the dialog just shows over an over
Re: dialog gender input -
d3Pedro - 15.03.2019
You can also do the dialog as a select list instead of input.
pawn Код:
ShowPlayerDialog(playerid, GENDER_DIALOG_ID, DIALOG_STYLE_LIST, "Select your gender", "Male\nFemale", "Select", "Close");
//OnDialogReponse
switch(dialogid)
{
case GENDER_DIALOG_ID:
{
if(response)
{
switch(listitem)
{
case 0: PlayerInfo[playerid][Gender] = 1; //player is a male
case 1: PlayerInfo[playerid][Gender] = 2; //player is a female
}
}
}
}
Re: dialog gender input -
v4yne1 - 15.03.2019
Quote:
Originally Posted by ConnorW
You can also do the dialog as a select list instead of input.
pawn Код:
ShowPlayerDialog(playerid, GENDER_DIALOG_ID, DIALOG_STYLE_LIST, "Select your gender", "Male\nFemale", "Select", "Close");
//OnDialogReponse switch(dialogid) { case GENDER_DIALOG_ID: { if(response) { switch(listitem) { case 0: PlayerInfo[playerid][Gender] = 1; //player is a male case 1: PlayerInfo[playerid][Gender] = 2; //player is a female } } } }
|
yeah, i know that.
but i want to do it with an input dialog
Re: dialog gender input -
d3Pedro - 15.03.2019
Quote:
Originally Posted by v4yne1
yeah, i know that.
but i want to do it with an input dialog
|
Here
pawn Код:
if(dialogid == DIALOG_GENDER)
{
if(!response)
{
Kick(playerid);
}
else
{
if(response)
{
if (!strcmp(inputtext, "male"))
{
PlayerInfo[playerid][Gender] = 1; // male
SendClientMessage(playerid, -1, "You are a male");
}
else if (!strcmp(inputtext, "female"))
{
PlayerInfo[playerid][Gender] = 2;
SendClientMessage(playerid, -1, "You are a female");
}
else {
return ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Gender","What is the gender of your character? (male/female)","Next","Quit");
}
}
}
}
Re: dialog gender input -
v4yne1 - 15.03.2019
Quote:
Originally Posted by ConnorW
Here
pawn Код:
if(dialogid == DIALOG_GENDER) { if(!response) { Kick(playerid); } else { if(response) { if (!strcmp(inputtext, "male")) { PlayerInfo[playerid][Gender] = 1; // male SendClientMessage(playerid, -1, "You are a male"); } else if (!strcmp(inputtext, "female")) { PlayerInfo[playerid][Gender] = 2; SendClientMessage(playerid, -1, "You are a female"); } else { return ShowPlayerDialog(playerid, DIALOG_GENDER, DIALOG_STYLE_INPUT, "Gender","What is the gender of your character? (male/female)","Next","Quit"); } } } }
|
thanks <3
Quote:
Originally Posted by SymonClash
Excuse me, but what's the point of using an input dialog? I still can write "my gender is not your business" and it'll be saved. I can't see the sense. Just make a dialog list. Avoid any further trolling from players.
|
its just matter of ideas and learning. from this example i can see how to use it in future and etc.
ty guys