strcmp Doesn't work? - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: strcmp Doesn't work? (
/showthread.php?tid=328912)
strcmp Doesn't work? -
REDPILL - 26.03.2012
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?
Re: strcmp Doesn't work? -
REDPILL - 26.03.2012
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.