OnPlayerText
#1

I want to make, when player in OnPlayerText type text which contains forbbiden word or some IP adress to send message only to admins, but not to show the text. How can I do it? Thank you.
Reply
#2

Код:
public OnPlayerText(playerid, text[])
{
    if(strfind(text, "fucker", true) != -1)
    {
	  SendClientMessage(playerid, 0xFF0000AA, "Forbidden Word.");
	  return 0;
    }
    if(strfind(text, "bitch", true) != -1)
    {
	  SendClientMessage(playerid, 0xFF0000AA, "Forbidden Word.");
	  return 0;
    }
    return 1;
}
Reply
#3

Quote:
Originally Posted by CH | FuDo
Посмотреть сообщение
I want to make, when player in OnPlayerText type text which contains forbbiden word or some IP adress to send message only to admins, but not to show the text. How can I do it? Thank you.
pawn Код:
//A function called "DetectAdv" which will detect if an IP is found on the str.

stock DetectAdv(stradv[])
{
    new temp_Count;
    for(new i; stradv[i] != 0; ++i) {
        if(('0' <= stradv[i] <= '9') || stradv[i] == '.' || stradv[i] == ':') {
            if((stradv[i] == '.') && (stradv[i + 1] != '.') && ('0' <= stradv[i - 1] <= '9')) {
                ++temp_Count;
            }
            continue;
        }
    }
    return (temp_Count > 2);
}

//An array called "badwords" which contains a list of badwords.


new badwords[][] =
{
    {"fuck"},
    {"bitch"},
    {"asshole"}}; //You can add more, the last word doesn't need to have a , .

public OnPlayerText(playerid, text[])
{
    new
        bool:Found = false;
    for(new i; i< sizeof(badwords); i++) //Looping around the array which contains badwords.
    {
        //If the chat contains any words specified on the array, it will detect.
        if(strfind(text, badwords[i], true) != -1) Found = true;
    }
    if(DetectAdv(text)) Found = true; //Or if an IP is pasted, it will detect.
    if(Found == true) //If detected!
    {
        new
            string[128],
            Lname[MAX_PLAYER_NAME];
        //Getting the player's name to show it to admins.
        GetPlayerName(playerid, Lname, sizeof(Lname));
        //Formatting the text to show it to admin with player's name and ID!
        format(string, sizeof(string), "%s(ID:%d) : %s", Lname, playerid, text);
        for(new i; i< GetMaxPlayers(); i++) //Looping through all players.
        {
            if(!IsPlayerConnected(i)) continue; //If not connected, it will skip.
            if(!IsPlayerAdmin(i)) continue; //The same goes here too.
            SendClientMessage(i, -1, string); //Sends to online RCON admins.
        }
        return !SendClientMessage(playerid, 0xFF0000FF, "Warning! You're not allowed to use forbidden chat!");
    }
    return 1;
}
Haven't tested on game, but it seems to be working.
Reply
#4

Quote:
Originally Posted by Lordz™
Посмотреть сообщение
pawn Код:
//A function called "DetectAdv" which will detect if an IP is found on the str.

stock DetectAdv(stradv[])
{
    new temp_Count;
    for(new i; stradv[i] != 0; ++i) {
        if(('0' <= stradv[i] <= '9') || stradv[i] == '.' || stradv[i] == ':') {
            if((stradv[i] == '.') && (stradv[i + 1] != '.') && ('0' <= stradv[i - 1] <= '9')) {
                ++temp_Count;
            }
            continue;
        }
    }
    return (temp_Count > 2);
}

//An array called "badwords" which contains a list of badwords.


new badwords[][] =
{
    {"fuck"},
    {"bitch"},
    {"asshole"}}; //You can add more, the last word doesn't need to have a , .

public OnPlayerText(playerid, text[])
{
    new
        bool:Found = false;
    for(new i; i< sizeof(badwords); i++) //Looping around the array which contains badwords.
    {
        //If the chat contains any words specified on the array, it will detect.
        if(strfind(text, badwords[i], true) != -1) Found = true;
    }
    if(DetectAdv(text)) Found = true; //Or if an IP is pasted, it will detect.
    if(Found == true) //If detected!
    {
        new
            string[128],
            Lname[MAX_PLAYER_NAME];
        //Getting the player's name to show it to admins.
        GetPlayerName(playerid, Lname, sizeof(Lname));
        //Formatting the text to show it to admin with player's name and ID!
        format(string, sizeof(string), "%s(ID:%d) : %s", Lname, playerid, text);
        for(new i; i< GetMaxPlayers(); i++) //Looping through all players.
        {
            if(!IsPlayerConnected(i)) continue; //If not connected, it will skip.
            if(!IsPlayerAdmin(i)) continue; //The same goes here too.
            SendClientMessage(i, -1, string); //Sends to online RCON admins.
        }
        return !SendClientMessage(playerid, 0xFF0000FF, "Warning! You're not allowed to use forbidden chat!");
    }
    return 1;
}
Haven't tested on game, but it seems to be working.
I modificated it, and it works, but if player write "f u ck" and smthg like that, it not useful.. Can U fix it? Thank you.
Reply
#5

You couldnt really fix that problem when they say "f u c k" because they are bypassing that word

You could try this:
Код:
new badwords[][] =
{
    {"fuck"},
    {"bitch"},
    {"asshole"}
    {"f u c k"}}; //You can add more, the last word doesn't need to have a , .
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)