You can even do this with "tutorials that explain how to find characters in a string":
pawn Код:
// ** INCLUDES
#include <a_samp>
// ** MAIN
main()
{
print("Loaded \"find_string_in_string.amx\".");
if(ContainsStringInString("Hello. How are you?", "."))
{
print("Specified string was found.");
}
else
{
print("Specified string wasn't found.");
}
}
// ** CALLBACKS
public OnGameModeInit()
{
return 1;
}
public OnGameModeExit()
{
return 1;
}
// ** FUNCTIONS
forward bool:ContainsStringInString(const search[], const find[]);
public bool:ContainsStringInString(const search[], const find[])
{
if(strfind(search, find) != -1) return true;
return false;
}
And by using some common sense while studying the condition "if(strfind(search, find) != -1)", you'd notice the following:
If what is returned by the function is not -1, means that the specified string was found. Then what is -1, would mean that the specified string was found.
pawn Код:
if(strfind(search, find) == -1) return false;
@RoboN1X - Once you're done with the loop, use
break then return the value afterwards. And there is no need to use loops whatsoever in this case, use strfind when it comes to finding strings in non-defined spots in other strings. If you want to compare one cell, then you could use "if(text[0] == '.')" for example.