SA-MP Forums Archive
STRCMP bug? - 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 bug? (/showthread.php?tid=641927)



STRCMP bug? - Kampott - 22.09.2017

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?


Re: STRCMP bug? - ToiletDuck - 22.09.2017

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;
			}



Re: STRCMP bug? - SlowARG - 22.09.2017

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

Regards.


Re: STRCMP bug? - Kampott - 22.09.2017

Thanks for the two people above.