SA-MP Forums Archive
strfind - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: strfind (/showthread.php?tid=69374)



strfind - russiany - 17.03.2009

If got a problema guys , i didn't understand what's happend if he returns -1 if he is not found

Returns The occurance of the substr, returns -1 if it's not found.


Re: strfind - MenaceX^ - 17.03.2009

Nothing happens?


Re: strfind - [RP]Rav - 17.03.2009

strfind returns the starting characters position of the substring found in string, strings start at bit 0,

Hello is
0 --> H
1 --> E
2 --> L
3 --> L
4 --> O

when you try to find "ll" in "hello", it would return 2. Now if we try to find "hi" in "hello", it returns -1 because it can't find it.

pawn Код:
if (strfind("hello", "hi", true) > -1) // it's bigger than -1, thus found
{
  // this is where the magic happens
}