Anti-Advertisement issue
#1

Hello.
I'm trying to create it where anyone advertises, our server automatically bans them.
Currently it only does it in local chat, but no in chats that use commands like /b or /pm
Heres my coding, any assistance?

OnPlayerCommandText
pawn Код:
public OnPlayerCommandText(playerid,cmdtext[])
{
    /*if(PlayerCmdFrq[playerid] != 0)
    {
        SendClientMessage(playerid, COLOR_LIGHTRED, "You must wait before using another command.");
        return 1;
    }*/

    if(stringContainsIP(cmdtext))
    {
        /*new szMsg[128];
        GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);

        format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
        SendClientMessageToAll(0xFF0000FF, szMsg);*/

        SystemBanPlayer(playerid, "Server Advertising", PlayerInfo[playerid][pIP]);
    }
    //return PlayerCmdFrq[playerid] = 3;
    return 0;
}
OnPlayerText (This works)
pawn Код:
public OnPlayerText(playerid, text[]) {
    IdleInfo[playerid][idleX]++;
    IdleInfo[playerid][idleY]++;
    IdleInfo[playerid][idleZ]++;
    IdleInfo[playerid][minCounter] = 0;
    if(IdleInfo[playerid][idleMode] != 0) {
        IdleInfo[playerid][unset] = 1;
    }
   
    if(stringContainsIP(text))
    {
        /*new szMsg[128];
        GetPlayerName(playerid, szMsg, MAX_PLAYER_NAME);

        format(szMsg, sizeof(szMsg), "%s has been banned due advertising!", szMsg);
        SendClientMessageToAll(0xFF0000FF, szMsg);*/

        SystemBanPlayer(playerid, "Server Advertising", PlayerInfo[playerid][pIP]);
    }
   //bunch of other stuff below this then..
   return 0;
}
The stock
pawn Код:
stock stringContainsIP(const szStr[])
{
    new
        iDots,
        i
    ;
    while(szStr[i] != EOS)
    {
        if('0' <= szStr[i] <= '9')
        {
            do
            {
                if(szStr[i] == '.')
                    iDots++;

                i++;
            }
            while(('0' <= szStr[i] <= '9') || szStr[i] == '.' || szStr[i] == ':' || szStr[i] == '/' || szStr[i] == '(' || szStr[i] == ')');
        }
        if(iDots > 2)
            return 1;
        else
            iDots = 0;

        i++;
    }
    return 0;
}
Would love some help everyone!
Reply
#2

Separate the whole block into a separate function and then feed playerid and text into the new function. Place function where necessary.
Reply
#3

This function doesn't make any sense in OnPlayerCommandText. You should check if player is trying send IP number through certain commands, for instance private message or announce commands or any other commands that are sending messages to the player(s).

Your way of doing it is wrong. Also, what would happen if I join the server and text in the chat "Oh, the number is 9912... dummy.."

I think it's going to ban me. Either way it is too rough to ban player, since you might have some false positives, so you should kick them out instead.

edit:// @Vince,
You got me first, damn forum's antispam system.
Reply
#4

Quote:
Originally Posted by Vince
Посмотреть сообщение
Separate the whole block into a separate function and then feed playerid and text into the new function. Place function where necessary.
That's what I've had an issue doing, I don't know how to separate it where it'll work that way so if they type in /b, or /f or /pm with the IP that it will check it, and take the action accordingly

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
This function doesn't make any sense in OnPlayerCommandText. You should check if player is trying send IP number through certain commands, for instance private message or announce commands or any other commands that are sending messages to the player(s).

Your way of doing it is wrong. Also, what would happen if I join the server and text in the chat "Oh, the number is 9912... dummy.."

I think it's going to ban me. Either way it is too rough to ban player, since you might have some false positives, so you should kick them out instead.

edit:// @Vince,
You got me first, damn antispam number count.
No, I've tested, it won't do that. But I do not know how to separate it into a command, that too being my issue.
Reply
#5

Quote:
Originally Posted by Jhero
Посмотреть сообщение
That's what I've had an issue doing, I don't know how to separate it where it'll work that way so if they type in /b, or /f or /pm with the IP that it will check it, and take the action accordingly[...]
You just simply need to check message that player has sent to another player. String that you need to pass by reference depends on the name of your variable array in your command.
Reply
#6

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
You just simply need to check message that player has sent to another player. String that you need to pass by reference depends on the name of your variable array in your command.
I'm sorry lol I'm a noob at the function shit. I'm not understanding. An example would be nice?
Reply
#7

Here is the PM Command
pawn Код:
COMMAND:pm(playerid, params[]) {
    if(GetPVarInt(playerid, "Muted") == 1) return SendClientMessage(playerid, COLOR_LIGHTRED, "SERVER: You are currently muted.");
    new message[128],
        user;

    if(sscanf(params, "us[128]", user, message)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /pm [playerid] [message]");
    if(user == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is either invalid or a maskID).");
    if(!IsPlayerConnected(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID is not connected).");
    if(IsPlayerNPC(user)) return SendClientMessage(playerid, COLOR_GREY, "Invalid playerID (Submitted playerID points at NPC).");
    if(user == playerid) return SendClientMessage(playerid, COLOR_GREY, "You cannot send yourself private messages.");
    if(GetPVarInt(user, "TogglePM") == 1 && PlayerInfo[playerid][pAdminlevel] == 0 && PlayerInfo[playerid][pModLevel] == 0) return SendClientMessage(playerid, COLOR_GREY, "The Private Messages of this user are currently blocked.");
    new len = strlen(message);
    if(len + MAX_PLAYER_NAME + 30 > 128) {
        new buffer[128],
            msg[128];
        strmid(buffer, message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
        format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ... ))", GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, buffer);
        SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
        format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: %s ... ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, buffer);
        SendClientMessage(user, COLOR_YELLOW, msg);
        strdel(message, 0, 128 - MAX_PLAYER_NAME - 30 - 4);
        format(msg, sizeof(msg), "(( PM sent to%s %s{E5C43E} [ID: %i]: ... %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}"), GetNameWithSpace(user), user, message);
        SendClientMessage(playerid, COLOR_DARKYELLOW, msg);
        format(msg, sizeof(msg), "(( PM from%s %s{F0F000} [ID: %i]: ... %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
        SendClientMessage(user, COLOR_YELLOW, msg);
    } else {
        new buffer[128];
        format(buffer, sizeof(buffer), "(( PM sent to%s %s{E5C43E} [ID: %i]: %s ))",GetPVarInt(user, "AdminDuty") != 0? ("{CC9900}") : ("{E5C43E}") , GetNameWithSpace(user), user, message);
        SendClientMessage(playerid, COLOR_DARKYELLOW, buffer);
        format(buffer, sizeof(buffer), "(( PM from%s %s{F0F000} [ID: %i]: %s ))", GetPVarInt(playerid, "AdminDuty") != 0? ("{CC9900}") : ("{F0F000}"), GetNameWithSpace(playerid), playerid, message);
        SendClientMessage(user, COLOR_YELLOW, buffer);
    }

    SetPVarInt(user, "lpm", playerid);
    return 1;
}
Reply
#8

Quote:
Originally Posted by Riddick94
Посмотреть сообщение
This function doesn't make any sense in OnPlayerCommandText. You should check if player is trying send IP number through certain commands, for instance private message or announce commands or any other commands that are sending messages to the player(s).

Your way of doing it is wrong. Also, what would happen if I join the server and text in the chat "Oh, the number is 9912... dummy.."

I think it's going to ban me. Either way it is too rough to ban player, since you might have some false positives, so you should kick them out instead.

edit:// @Vince,
You got me first, damn forum's antispam system.
I also wouldn't kick them out, just de-sync the message and block it somehow, so it won't get sent to the other player.
Would be quite rude to get kicked from a server when the script sees your number as a false positive.
Reply
#9

https://sampforum.blast.hk/showthread.php?tid=568668

Recommended: http://www.mediafire.com/view/79g5n5...nti_advert.pwn
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)