Checking if a string doesn't match, doesn't work?
#1

pawn Code:
if(strcmp(plate, VehPlate[x], false))return SendClientMessage(playerid, COLOUR_GREY, "That license plate does not exist.");
This returns each time.

Is that correct?
Reply
#2

If you're checking if they DO match, you need to check if the return value is false.

i.e.
pawn Code:
if(!strcmp(...))
Reply
#3

I see thank you!
Reply
#4

But he's checking if they 'don't' match, which is the exact opposite. The code you have now is correct, but it will be case sensitive.

So lets say a valid license plate was "ABC123". If you put in 'abc123', it will return true and it will say the license plate does not exist. However if you put 'ABC123', it will return false and the plates will match. To remove this, just change the case sensitivity or 'ignorecase' to true.

If this code doesn't work, then your VehPlate[x] or possibly the loop that you're using it in, is wrong.
pawn Code:
if(strcmp(plate, VehPlate[x], true)) return SendClientMessage(playerid, COLOUR_GREY, "That license plate does not exist.");
Take note, strcmp also returns false if either of the strings is empty.
Reply
#5

Thank you! I was looking incorrectly as I didn't put a condition and it used the first result in the loop each time, resolved!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)