strcmp problem
#1

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.
Reply
#2

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

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

Show me OnPlayerLogin(playerid, LOGIN_NORMAL);
Reply
#5

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

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 !?
Reply
#7

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

I tried:

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

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

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)