Dialog string check -
Hipflop - 09.07.2011
Hello,
I want to know what the player's gender is.
The way I do this is by Dialog.
Now, the problem is that I can't check if the inputtext is Male or Female.
My code:
pawn Code:
if(dialogid == 8)
{
if(response)
{
if(inputtext == "Male" || inputtext == "male") // Line 955
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Male.");
gPlayerInfo[playerid][pSex] = 1;
}
else if(inputtext == "Female" || inputtext == "female") // Line 960
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Female.");
gPlayerInfo[playerid][pSex] = 2;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to choose between Male or Female!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to fill in what your gender is!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
And the error I get is:
pawn Code:
D:\GTASAN~1\server\GAMEMO~1\RRP.pwn(955) : error 001: expected token: "-string end-", but found "-identifier-"
D:\GTASAN~1\server\GAMEMO~1\RRP.pwn(960) : error 001: expected token: "-string end-", but found "-identifier-"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
Thanks in advance!
Re: Dialog string check -
Cyanide - 09.07.2011
The function
strcmp's purpose is to compare strings.
Re: Dialog string check -
Hipflop - 09.07.2011
Something like this?
pawn Code:
if(dialogid == 8)
{
if(response)
{
if((strcmp(inputtext, "Male", true) == 0) || (strcmp(inputtext, "male", true) == 0))
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Male.");
gPlayerInfo[playerid][pSex] = 1;
}
else if((strcmp(inputtext, "Female", true) == 0) || (strcmp(inputtext, "female", true) == 0))
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Female.");
gPlayerInfo[playerid][pSex] = 2;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to choose between Male or Female!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to fill in what your gender is!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
Re: Dialog string check -
=WoR=Varth - 09.07.2011
Well you can do this fo less word
pawn Code:
(!strcmp(inputtext,"male"))
Re: Dialog string check -
Cyanide - 09.07.2011
Yes, it looks fine.
Re: Dialog string check -
Hipflop - 09.07.2011
Fixed it:
pawn Code:
if(dialogid == 8)
{
if(response)
{
if(strlen(inputtext))
{
if((strcmp(inputtext, "Male", true) == 0) || (strcmp(inputtext, "male", true) == 0))
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Male.");
gPlayerInfo[playerid][pSex] = 1;
}
else if((strcmp(inputtext, "Female", true) == 0) || (strcmp(inputtext, "female", true) == 0))
{
SendClientMessage(playerid, COLOR_GREEN, "So you are a Female.");
gPlayerInfo[playerid][pSex] = 2;
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to choose between Male or Female!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
else
{
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You need to fill in what your gender is!");
ShowPlayerDialog(playerid, 8, DIALOG_STYLE_INPUT, "Sex", "What gender are you?\n\nMale / Female", "Ok", "Cancel");
}
}
No errors.