Little help :s - 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)
+--- Thread: Little help :s (
/showthread.php?tid=281927)
Little help :s -
FireCat - 08.09.2011
I have a function DisableBadWord found in a thread in filter script section.
If I have under OnPlayerText DisableBadWord("fuck"); and a player types fuck it will send ****
But I have a var to store words but when he types a word that is in that var it doesn't send ****
It sends the word

Why?
pawn Код:
public OnPlayerText(playerid, text[])
{
for(new j = 0; j < ForbidenWordsLoaded; j++)
{
DisableBadword(ForbidenWords[j]);
}
return 1;
}
pawn Код:
function LoadForbidenWords()
{
new File:handle = fopen("FAdmin/Logs/Forbidenwords.txt", io_read),word[32],i = 0;
while(fread(handle, word))
{
if(i >= sizeof(ForbidenWords))
{
printf("Warning: Could not load more than %d words. Destination array is too small!",sizeof(ForbidenWords));
break;
}
strcpy(ForbidenWords[i], word);
printf("%s",ForbidenWords[i]);
i++;
}
ForbidenWordsLoaded = i;
fclose(handle);
printf("Words loaded: %d", ForbidenWordsLoaded);
return 1;
}
Re: Little help :s -
=WoR=Varth - 08.09.2011
pawn Код:
public OnPlayerText(playerid, text[])
{
for(new j = 0; j < ForbidenWordsLoaded; j++)
{
DisableBadword(ForbidenWords[j]);
}
return 1;
}
I don't see anything touch "text" there.
Re: Little help :s -
JaTochNietDan - 08.09.2011
How are we supposed to help without knowing the contents of the DisableBadword function?
Re: Little help :s -
FireCat - 08.09.2011
Quote:
Originally Posted by JaTochNietDan
How are we supposed to help without knowing the contents of the DisableBadword function? 
|
:b...
Quote:
Originally Posted by Rafelder_GRF
DisableBadWord(word[])
word[] - word which will be disabled
pawn Код:
#define DisableBadword(%1) for(new i=0; i<strlen(text); i++) if(strfind(text[i], %1, true) == 0) for(new a=0; a<256; a++) if (a >= i && a < i+strlen(%1)) text[a]='*'
|
Re: Little help :s -
FireCat - 08.09.2011
Quote:
Originally Posted by ******
Seriously, just use normal functions!
|
What? :/
Re: Little help :s -
iPLEOMAX - 08.09.2011
Quote:
Originally Posted by varthshenon
pawn Код:
public OnPlayerText(playerid, text[]) { for(new j = 0; j < ForbidenWordsLoaded; j++) { DisableBadword(ForbidenWords[j]); } return 1; }
I don't see anything touch "text" there.
|
+1. Where is it doing something with the text[] parameter of OnPlayerText? It doesn't get processed, Meaning it doesn't even modify the player's message... So, how can it censor stuff?
Re: Little help :s -
FireCat - 08.09.2011
Quote:
Originally Posted by iPLEOMAX
+1. Where is it doing something with the text[] parameter of OnPlayerText? It doesn't get processed, Meaning it doesn't even modify the player's message... So, how can it censor stuff?
|
Uhh..
pawn Код:
#define DisableBadword(%1) for(new i=0; i<strlen(text); i++) if(strfind(text[i], %1, true) == 0) for(new a=0; a<256; a++) if (a >= i && a < i+strlen(%1)) text[a]='*'
EDIT:
For you to see that it works:

EDIT 2:
Here is my command
pawn Код:
CMD:forbidword(playerid,params[])
{
if(PInfo[playerid][Level] < 3) return SendNeedLevel(playerid,3);
new word[20],tempstr[23];
if(sscanf(params,"s",word)) return SendClientMessage(playerid,green2,"USAGE: /forbidword "cyellow"<word>");
new File:Forbidenwordsfile;
Forbidenwordsfile = fopen("FAdmin/Logs/Forbidenwords.txt", io_append);
format(tempstr,sizeof(tempstr),"%s\n",word);
fwrite(Forbidenwordsfile, tempstr);
fclose(Forbidenwordsfile);
LoadForbidenWords();
return 1;
}