Strcmp
From SA-MP
strcmp
| string1 | The first string to compare. |
| string2 | The second string to compare. |
| ignorecase (optional) | When set to true, the case doesn't matter - HeLLo is the same as Hello. When false, they're not the same. |
| length (optional) | When this length is set, the first x chars will be compared - doing "Hello" and "Hell No" with a length of 4 will say it's the same string. |
| Returns | 0 if the strings are the same. |
Good examples of using strcmp can be found at the Using strcmp()-Tutorial.
Note:
(for problems on comparing strings from a textfile)
It is recomment to use strlen(one of your strings) for the lentgh param. If you don't and compare one string from a textfile with an other variable strcmp will not return 0 (only if length is larger then the string in the file).
This is because the string in the file got the \r\n for the line return on its end.
So if you use strcmp to compare textfile strings do that like this:
strcmp(stringfromvariable,stringfromatextfile,true or false, getlength(stringfromvariable))
so the \r\n in your file will be ignored because it is out out the range to compare!
Related Functions
The following functions might be useful as well, as they're related to this function in one way or another.
