***** Censorship
#1

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
Reply
#2

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...
Reply
#3

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

Reply
#4

...

PHP код:

new badwords[][] = {"fuck""bitch"};
public 
OnPlayerText(playeridtext[]){
    for(new 
ipossizeof badwordsi++){
        while((
pos strfind(textbadwords[i], true), pos) != -1){
            for(new 
pstrlen(badwords[i]) - 1p++){
                
text[pos 1] = '*';
            }
        }
    }
    
    
//...
    
return 1;

Reply
#5

I posted a better one in Useful Functions btw.
Reply
#6

AbyssMorgan Thank you very much
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)