SA-MP Forums Archive
strcmp problem - 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 problem (/showthread.php?tid=282088)



strcmp problem - Cank - 09.09.2011

hello,

I have a problem with the return value of strcmp:

pawn Код:
//OnDialogResponse
if(!strcmp("123", inputtext,  false)) return OnPlayerLogin(playerid, LOGIN_NORMAL);
Problem: when I type nothing into the dialog (inputtext is empty) strcmp returns 0.


Re: strcmp problem - FireCat - 09.09.2011

pawn Код:
if(!strlen(inputtext)) return ShowPlayerDialog your dialog here...



Re: strcmp problem - Cank - 09.09.2011

yes, but I want to know why strcmp returns 0 in this case.


Re: strcmp problem - FireCat - 09.09.2011

Show me OnPlayerLogin(playerid, LOGIN_NORMAL);


Re: strcmp problem - Wesley221 - 09.09.2011

pawn Код:
if(!strcmp(inputtext, "123", false)) return .......();
Try it like this


Re: strcmp problem - Cank - 09.09.2011

Quote:
pawn Код:
if(!strcmp(inputtext, "123", false)) return .......();
Try it like this

didn't help

Quote:

Show me OnPlayerLogin(playerid, LOGIN_NORMAL);

it has nothing to do with that. when "inputtext" is empty or inputtext is "123" OnPlayerLogin gets called, so there's somethng weong with strcmp !?


Re: strcmp problem - =WoR=Varth - 09.09.2011

Try using length?
https://sampwiki.blast.hk/wiki/Strcmp


Re: strcmp problem - Cank - 09.09.2011

I tried:

pawn Код:
if(!strcmp(inputtext, "123",  false, 3))
same as before.


Re: strcmp problem - JaTochNietDan - 09.09.2011

Yes, strcmp will return 0 if either of the strings are empty, that's just how it works!


Re: strcmp problem - Cank - 09.09.2011

Quote:

Yes, strcmp will return 0 if either of the strings are empty, that's just how it works!

oh, I didn't know about that. Thanks.