***** Censorship
#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


Messages In This Thread
***** Censorship - by James585 - 01.03.2016, 16:01
Re: ***** Censorship - by Crayder - 01.03.2016, 16:13
Re: ***** Censorship - by James585 - 01.03.2016, 18:06
Re: ***** Censorship - by AbyssMorgan - 01.03.2016, 18:21
Re: ***** Censorship - by Crayder - 01.03.2016, 18:29
Re: ***** Censorship - by James585 - 01.03.2016, 18:33

Forum Jump:


Users browsing this thread: 1 Guest(s)