Anty Flood (example: aaaaaaaaaa) -
Zamek - 10.10.2017
Hey! How to check if the player sent a string next to each other?
Example: "helllllllllllllllllllllllo"
Regards
Re: Anty Flood (example: aaaaaaaaaa) -
Prokill911 - 10.10.2017
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?
Re: Anty Flood (example: aaaaaaaaaa) -
n00blek - 10.10.2017
he probably meant on amount of same letters/characters in string
Re: Anty Flood (example: aaaaaaaaaa) -
Zamek - 10.10.2017
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?
Re: Anty Flood (example: aaaaaaaaaa) -
Jefff - 10.10.2017
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;
}
?
Re: Anty Flood (example: aaaaaaaaaa) -
AndreiWow - 10.10.2017
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.
Re: Anty Flood (example: aaaaaaaaaa) -
CodeStyle175 - 10.10.2017
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;
}
Re: Anty Flood (example: aaaaaaaaaa) -
Zamek - 10.10.2017
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?
Re: Anty Flood (example: aaaaaaaaaa) -
Prokill911 - 10.10.2017
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.
Re: Anty Flood (example: aaaaaaaaaa) -
Jefff - 10.10.2017
only 1 character extra so you cant type xDDD because there is D + DD (two DD not one), correct usage is xD or xDD