strcmp Doesn't work?
#1

Ok so I am completely stumped by this. The if statement never runs. Basically this is a check to see if the user chose a gender. By default the gender is set to "N" for no gender. The user chooses a gender and its changed to M or F. I'm attempting to do this via strcmp, here is the code:

Код:
format(strking, sizeof(strking), "strcmp(PlayerInfo[playerid][tGender], 'N') = '%d'", strcmp(PlayerInfo[playerid][tGender], "N"));
print(strking);
if(strcmp(PlayerInfo[playerid][tGender], "N") == 0)
{
     format(strking, sizeof(strking), "Must choose gender.");
     ShowPlayerDialog(playerid, 1, DIALOG_STYLE_MSGBOX, "Finish", strking, "Cancel", "");
}
format(strking, sizeof(strking), "Gender passed with '%s' as its value.", PlayerInfo[playerid][tGender]);
print(strking);
Output:
[11:06:09] strcmp(PlayerInfo[playerid][tGender], 'N') = '0'
[11:06:09] Gender passed with 'N' as its value.

Now if I give the player a gender:

[11:06:45] strcmp(PlayerInfo[playerid][tGender], 'N') = '-1'
[11:06:45] Gender passed with 'M' as its value.

How can this be?
Reply
#2

Well I figured it out. I had other IF statements after that utilized the same dialog and it was overriding the first dialog which was gender. Doh.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)