STRCMP bug?
#1

so, this is basically my code
Code:
new name[25];
			GetPlayerName(playerid, name, 25);
			new house = pInfo[playerid][pIH];
			if(strcmp(hInfo[house][hOwner], name, true, sizeof(name)))		
			{
				print("?");
				ShowPlayerDialog(playerid, BHIM, DIALOG_STYLE_LIST, ""#COL_WHITE"House Owner Menu", "Close/Open house\nHouse Info\nUse Safe\nUse Freezer\nUse Store\nSee Last House Visitors List\nRespawn Car\nSell Car", "Select", "Close");
			}
			else
			{
				printf("%s %s",name,hInfo[house][hOwner]);
				return 1;
			}
At the end, it shows in console something like "Mynickname Mynickname", with no differences. What's the matter in here?
Reply
#2

Code:
if(strcmp(hInfo[house][hOwner], name, true) == 0)		
			{
				print("?");
				ShowPlayerDialog(playerid, BHIM, DIALOG_STYLE_LIST, ""#COL_WHITE"House Owner Menu", "Close/Open house\nHouse Info\nUse Safe\nUse Freezer\nUse Store\nSee Last House Visitors List\nRespawn Car\nSell Car", "Select", "Close");
			}
			else
			{
				printf("%s %s",name,hInfo[house][hOwner]);
				return 1;
			}
Reply
#3

If strcmp match, returns 0.
So your code must be if(strcmp(..) == 0)

Regards.
Reply
#4

Thanks for the two people above.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)