some problem with strfind function
#1

I try to build a censor words filter.. but I have a problem with the strfind function :

Global vars :

Код:
enum String { string[50] };
new words[MAX_WORDS][String];
Init the censor words array :

Код:
public OnFilterScriptInit()
{
	new File:fp;
	new count = 0;
	new word[50];
	fp = fopen("CensorWords.txt",io_read);
	while (fread(fp,word,sizeof(word))) words[count++][string] = word;
	printf("number of censor words : %d",count);
	word = "*EOF*";
	words[count][string] = word;
	fclose(fp);
	return 1;
}
until now all works... I tried to print all the array, it's work.

Here is the problem :

Код:
public OnPlayerText(playerid, text[])
{
  new censor[50], num;
  new line[128];
	for (new i=0; i<MAX_WORDS; i++)
	{
	  memcpy(censor,words[i][string],0,sizeof(censor));
	  if (!strcmp(censor,"*EOF*",true)) break;
	  SendClientMessage(playerid,0xff0022ff,censor);
 		num = strfind(text,censor,true);
		if (num != -1)
		{
		  format(line,sizeof(line),"%s message censored by the system !",GetName(playerid));
		  SendClientMessage(playerid,0xff0033ff,line);
		  return false;
		}
	}
	return true;
}
lets say the censor words are : one, two, three.
If I write in the game sentence with one or more of the words except the last one, nothing happens.
But if I write a sentence with the last word it's work and censor the sentence.

edit :

hmmmm... if I init the array like this :
new words[MAX_WORDS][MAX_STRING] = {"one","two","three","*EOF*"};

All works... so I guess the problem in the OnFilterScriptInit.. but what :\ ?
Reply
#2

$s message censored by the system
Why dollar($)?
Reply
#3

might be a leftover from php
Reply
#4

Quote:
Originally Posted by MenaceX^
$s message censored by the system
Why dollar($)?
my mistake.. when I transer this to the forum I change the message to english.
I edit something in the main message ^

Код:
edit :

hmmmm... if I init the array like this :
new words[MAX_WORDS][MAX_STRING] = {"one","two","three","*EOF*"};

All works... so I guess the problem in the OnFilterScriptInit.. but what :\ ?
I fix the problem.. you can lock :]
Reply
#5

As far as I know none locks here threads.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)