23.10.2013, 23:38
Today i learned how to detect a word from a single character for example...
If Player Abuses using the world "fuck". Then Using A "for" loop we can loop through the string lenght of players text and detect if theres a word 'f' and if yes detect if the words position + 1 is 'u' again check if position of f + 2 is 'u' and position of word + 3 is 'k' using LOGICAL AND..
Like
Well this is the longest way to detect a abusive word in players text but might be usefull to detect correct abusive words in the chat
If Player Abuses using the world "fuck". Then Using A "for" loop we can loop through the string lenght of players text and detect if theres a word 'f' and if yes detect if the words position + 1 is 'u' again check if position of f + 2 is 'u' and position of word + 3 is 'k' using LOGICAL AND..
Like
pawn Код:
public OnPlayerText(playerid,text[])
{
for(new i = 0; i <= strlen(text); i++)
{
if(text[i] == 'f' && text[i+1] == 'u' && text[i+2] == 'c' && text[i+3] == 'k') // Do Something
}
return 1;
}