• Welcome to Vice City Multiplayer.
 

System Anti-Spam/Flooding by Madara ( 2 forms ) (Modified)

Started by Madara, March 17, 2011, 12:14:15 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

Madara

Many are wondering how to make an anti-spam on your server, as a way of doing here with this little code, and i will show two different ways.

- FIRST FORM -

First of all, need to define a couple of words that will serve to check how many messages are sent through time, this must go down where are the lines #include.
And it is if:
#define LIMIT_REP_SPAM     3
#define MSNxSEC    1750


Now, will make new words, which define a word representing the player, whether as the gPlayers[playerid], but this time would be two, one for each message, and another post player, this must go down where all the define. And it would to if:

new MSNCount[MAX_PLAYERS];
new MSNPlayer[MAX_PLAYERS];


After that, they will put this little code that has sent the message by time, and located below the public OnPlayerText (playerid, cmdtext[]). And I would put sii:

public OnPlayerText(playerid, cmdtext[])
{

   new MSN[256],spammer = (GetTickCount()-MSNCount[playerid])/MSNxSEC;
   MSNPlayer[playerid]+=spammer-1;
   if(MSNPlayer[playerid]>LIMIT_REP_SPAM)MSNPlayer[playerid]=LIMIT_REP_SPAM-1;
   if(MSNPlayer[playerid]<0)MSNPlayer[playerid]=-1;
       MSNCount[playerid]=GetTickCount();
       if(MSNPlayer[playerid]<0) {
       format(MSN,256,">> Auto-Kick %s, ID %d, Reason: [ No Spam/Flooding ].", PlayerName(playerid), playerid);
       SendClientMessageToAll(0x377DFFFF,MSN);
       Kick(playerid);
return 1;
   }
   
 return 0;
}


This will get to kick players who send mass messages, and finally create the function that refers to the player's name:

stock PlayerName(playerid)
{
     new name[24];
     GetPlayerName(playerid,name,24);
     return name;
}


Now this kind of anti-spam is for those who send messages fast but with lyrics changed, but now, so those who send the same message, but slower than the time it gets a bit annoying, because here they teach the second form:

- SECOND FORM -

To begin with we will create a system of enumeration, this type of system stores numbers, text or decimal numbers on a player and places him at the top of our GM or where there are more of these. And is created if:

enum playerToSpamm
{
   CountText,
   LastText[256],
}


After that, you must create a new word which will be used this system along with the player that is building up the same, this will put it where it is located the other new, but example "new gPlayers[MAX_PLAYERS][MAX_PLAYERS_NAME+1];. And it would be something if:

new Spamming[MAX_PLAYERS][playerToSpamm];

Now, we move into the public OnPlayerText (playerid, cmdtext []);, and paste this line function of spamm:

public OnPlayerText(playerid, cmdtext[])
{
   PlayerSpamming(playerid,cmd,cmdtext);
   return 0;
}


And define that function down you GM, look:

public PlayerSpamming(playerid,cmd[],cmdtext[])
{
   if (strcmp(cmd, cmd, true) == 0) {
      if (strcmp(cmdtext, Spamming[playerid][LastText], true) == 0 && Spamming[playerid][CountText] >= 3) {format(MSN,256,">> Auto-Kick %s, ID %d, Reason: [ SPAMMING ].", PlayerName(playerid), playerid); SendClientMessageToAll(0x377DFFFF,MSN); Kick(playerid);}
      else {
   format(MSN,256,"%s", cmdtext);
           if (strcmp(cmd, Spamming[playerid][LastText], true) == 0) {Spamming[playerid][LastText] = MSN; Spamming[playerid][CountText] = Spamming[playerid][CountText] + 1;}
           else {Spamming[playerid][LastText] = MSN; Spamming[playerid][CountText] = 0;}
       }
}
return 1;
}


And with that we will have a kick by the same player to send messages over time.

By the way, I passed, in the "public OnPlayerDisconnect (playerid, reason), put it in an empty line:
public OnPlayerDisconnect(playerid, reason)
{
Spamming[playerid][CountText] = 0; // this in an empty line
return 1;
}


Well I hope you like it and comment if you have doubts, these codgis the job I did and I have different servers (including the one that got on this forum) and serves 100%, if they can not put it in your GM, and contacts to help me to put it.

     - OPTION 2 -
If they fail to put the codes right into your script, you can choose to lower my filterscript and add it to your server.

This filterscripts put it in the folder filterscript (if any) and if there add it, then you put in your server.cfg that is where your server, and inside it, add a line (if there) and named filterscripts below this the filter name "LMS".

    DOWNLOAD:Filterscript Anti-Spam to Mediafire  &&  Filterscript Anti-Spam to Megaupload

And that's all, for any questions or suggestions, let me know and we will gladly assist you.

Credits: YO ( Madara ).

Greetings  ;)

PD: Sorry for my bad English :-\


sseebbyy



Madara

I modified this code in the second form because they show how kick for spam, was a little conflict in commands:!

DivX


yazeen

If u knew English Better You Will Be one of the Best scripters in pawno

Best of luck in learining English

killvn1

Thanks Madara ! I add your script but it's only Work on Win Server ! Not Work on Linux Server !
In Win server it's work good but in linux server ! If you say anything you will get kick from server ... i don't know how can use this script for linux server !