Anty Flood (example: aaaaaaaaaa)
#1

Hey! How to check if the player sent a string next to each other?

Example: "helllllllllllllllllllllllo"

Regards
Reply
#2

Depends really what you're trying too do?
Prevent people from flooding chat?
Just ad a timer after they send a message, so they can't send another until the timer has expired?
Reply
#3

he probably meant on amount of same letters/characters in string
Reply
#4

Quote:
Originally Posted by n00blek
Посмотреть сообщение
he probably meant on amount of same letters/characters in string
That's exactly what I mean, does anyone have an idea?
Reply
#5

pawn Код:
IsPlayerFlooding(const string[])
{
    new cnt,len = strlen(string);
    for(new i,d; i < len-1; i++)
        for(d = i+1; d < len; d++)
            if(tolower(string[i]) == tolower(string[d]))
            {
                if(++cnt > 1)
                    return 1;
            }
            else
            {
                cnt = 0;
                break;
            }

    return 0;
}
?
Reply
#6

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
IsPlayerFlooding(const string[])
{
    new cnt,len = strlen(string);
    for(new i,d; i < len-1; i++)
        for(d = i+1; d < len; d++)
            if(tolower(string[i]) == tolower(string[d]))
            {
                if(++cnt > 1)
                    return 1;
            }
            else
            {
                cnt = 0;
                break;
            }

    return 0;
}
?
Could you also explain him? Not only give him to copy - paste.
Reply
#7

PHP код:
new FloodTC[MAX_PLAYERS]
    
FloodCnt[MAX_PLAYERS];

public 
OnPlayerText(playerid,text[]){
    if(
GetTickCount()-FloodTC[playerid] < 250){
        
FloodTC[playerid]=GetTickCount();
        if(++
FloodCnt[playerid]==3)Kick(playerid);
        else 
scm(playerid,-1,"STOP FLOODING!");
        return 
0;
    }
    
FloodCnt[playerid]=1;
    
FloodTC[playerid]=GetTickCount();
    return 
1;

Reply
#8

Quote:
Originally Posted by Jefff
Посмотреть сообщение
pawn Код:
IsPlayerFlooding(const string[])
{
    new cnt,len = strlen(string);
    for(new i,d; i < len-1; i++)
        for(d = i+1; d < len; d++)
            if(tolower(string[i]) == tolower(string[d]))
            {
                if(++cnt > 1)
                    return 1;
            }
            else
            {
                cnt = 0;
                break;
            }

    return 0;
}
?
Can you explain how to set the limit for the characters from which to detect the flood?
Reply
#9

To be honest you should be using regex but hey ho. not my code so using a loop will be fine for you, loops are not always good though especially if you have lets say 100 players and each player is being tested with that loop.
Enjoy the lag.
Reply
#10

pawn Код:
if(++cnt > 1)
only 1 character extra so you cant type xDDD because there is D + DD (two DD not one), correct usage is xD or xDD
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)