***** Censorship - 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: ***** Censorship (
/showthread.php?tid=602050)
***** Censorship -
James585 - 01.03.2016
Hey guys

I would need you to help me with censorship but when I write I curse so will send the message but it gives such a word.fuck = **** and the rest normally Thank you
Re: ***** Censorship -
Crayder - 01.03.2016
Example concept code:
Код:
#include <a_samp>
main()
{
new badwords[][] = {"fuck", "bitch"};
new input[] = "fuck you bitch"; // whatever string you want to test
print(input);
for (new i, pos; i < sizeof badwords; i++)
while ((pos = strfind(input, badwords[i], true), pos) != -1)
for (new p; p < strlen(badwords[i]); p++)
input[pos + p] = '*';
print(input);
}
EDIT: Tested, prints "**** you *****".
EDIT EDIT: The following code would censor everything except the first character:
Код:
#include <a_samp>
main()
{
new badwords[][] = {"fuck", "bitch"};
new input[] = "fuck you bitch"; // whatever string you want to test
print(input);
for (new i, pos; i < sizeof badwords; i++)
while ((pos = strfind(input, badwords[i], true), pos) != -1)
for (new p; p < strlen(badwords[i]) - 1; p++)
input[pos + p + 1] = '*';
print(input);
}
Output: "f*** you b*****"
EDIT EDIT EDIT: Added ignore case...
Re: ***** Censorship -
James585 - 01.03.2016
Thank you but when I put it the other main () to code so it did not work .. Here you have a picture, and I did put in other terms of abuse and sentence. What you get are nadavky not only in English
Re: ***** Censorship -
AbyssMorgan - 01.03.2016
...
PHP код:
new badwords[][] = {"fuck", "bitch"};
public OnPlayerText(playerid, text[]){
for(new i, pos; i < sizeof badwords; i++){
while((pos = strfind(text, badwords[i], true), pos) != -1){
for(new p; p < strlen(badwords[i]) - 1; p++){
text[pos + p + 1] = '*';
}
}
}
//...
return 1;
}
Re: ***** Censorship -
Crayder - 01.03.2016
I posted a better one in Useful Functions btw.
Re: ***** Censorship -
James585 - 01.03.2016
AbyssMorgan Thank you very much