Thread Rating:
  • 2 Vote(s) - 4 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release Anti Flood plugin
#1
This plugins basicly protects your server from spammers.

You can change some settings in the sv_config.ini:
Code:
[ANTIFLOOD]
warnings=3 //how much warnings will a player get
time=2 //the time in seconds that a player has to wait untill he can chat again
punish=true //true will kick the player after he has ignored his warnings, false will only hide the message

Source:
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Threading;
  4. using Addon;
  5.  
  6. namespace Anti_Flood
  7. {
  8. public class Anti_Flood : CPlugin
  9. {
  10. List<AntiFlood> Floodlist = new List<AntiFlood>();
  11. int MaxWarnings;
  12. int Time;
  13. bool Punish;
  14.  
  15. public override void OnServerLoad()
  16. {
  17. ServerPrint( "Anti-Flood plugin. Author: iAegle. Version: 1.0" );
  18. Time = Convert.ToInt32( Convert.ToDecimal( GetServerCFG( "ANTIFLOOD", "time", "2" ) ) * 50 );
  19. MaxWarnings = Convert.ToInt32( GetServerCFG( "ANTIFLOOD", "warnings", "3" ) );
  20. Punish = ( GetServerCFG( "ANTIFLOOD", "punish", "true" ) == "true" );
  21. }
  22.  
  23. public override void OnServerFrame()
  24. {
  25. foreach ( AntiFlood player in Floodlist )
  26. {
  27. player.Waittime--;
  28.  
  29. if ( player.Waittime == 0 )
  30. Floodlist.Remove( player );
  31. }
  32. }
  33.  
  34. public override ChatType OnSay( string Message, ServerClient Client )
  35. {
  36. foreach ( AntiFlood player in Floodlist )
  37. {
  38. if ( player.Client == Client )
  39. {
  40. if ( !Punish )
  41. return ChatType.ChatNone;
  42.  
  43. iPrintLnBold( ( player.Warnings <= 2 ) ? "Stop spamming! [^1Warnings Left" + ( 2 - player.Warnings ).ToString() + "^7]" : "^1You better pay attention the the warnings next time.", Client );
  44. if ( player.Warnings >= 3 )
  45. new Thread( new ParameterizedThreadStart( PunishThread ) ).Start( Client );
  46. else
  47. player.Warnings++;
  48.  
  49. return ChatType.ChatNone;
  50. }
  51. }
  52.  
  53. Floodlist.Add( new AntiFlood( Client, Time, MaxWarnings ) );
  54. return ChatType.ChatAll;
  55. }
  56.  
  57. public void PunishThread( object Client )
  58. {
  59. ServerClient client = ( ServerClient )Client;
  60. Thread.Sleep( 2500 );
  61. iPrintLnBold( "Bye bye spammer. :)", client );
  62. Thread.Sleep( 1000 );
  63. ServerCommand( "kickclient " + client.ClientNum );
  64. iPrintLn( client.Name + " got kicked for spamming.", null );
  65. }
  66.  
  67. public class AntiFlood
  68. {
  69. public int Waittime;
  70. public ServerClient Client;
  71. public int Warnings;
  72. public AntiFlood( ServerClient client, int time, int warnings )
  73. {
  74. Client = client;
  75. Waittime = time;
  76. Warnings = warnings;
  77. }
  78. }
  79. }
  80. }


Plugin:

.rar   mw3-anti-flood.rar (Size: 2.9 KB / Downloads: 175)

I didn't test it, but if something doesn't work properly please post the problem here.
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#2
(01-08-2012, 21:07)iAegle Wrote: I didn't test it, but if something doesn't work properly please post the problem here.

Code:
return ChatType.ChatAll;

should be (unless you want to break all other plugins):

Code:
return ChatType.ChatContinue;


Still, nice work
[Image: b_560_95_1.png]
Reply

#3
(01-08-2012, 21:09)Nukem Wrote:
(01-08-2012, 21:07)iAegle Wrote: I didn't test it, but if something doesn't work properly please post the problem here.

Code:
return ChatType.ChatAll;

should be (unless you want to break all other plugins):

Code:
return ChatType.ChatContinue;


Still, nice work

Why did you even include ChatType.ChatNone if you tell everyone to use ChatContinue :p?
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#4
Why do you never test your plugins
[Image: MaEIQ.png]
Reply

#5
(01-08-2012, 21:12)Pozzuh Wrote: Why do you never test your plugins

Ohh thats simple, because I can't :p
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#6
(01-08-2012, 21:12)iAegle Wrote:
(01-08-2012, 21:12)Pozzuh Wrote: Why do you never test your plugins

Ohh thats simple, because I can't :p

why cant you
[Image: MaEIQ.png]
Reply

#7
lol @ 6 reactions and 0 downloads Troll
Reply

#8
(01-08-2012, 21:17)Pozzuh Wrote:
(01-08-2012, 21:12)iAegle Wrote:
(01-08-2012, 21:12)Pozzuh Wrote: Why do you never test your plugins

Ohh thats simple, because I can't :p

why cant you

No game/server
(08-10-2011, 12:58)Pozzuh Wrote:
Se7en Wrote:Stealed, from cod4 mod ...
look who's talking

[Release] Old School Mod v2.2
[Release] Scroll menu

Reply

#9
(01-08-2012, 21:27)iAegle Wrote:
(01-08-2012, 21:17)Pozzuh Wrote:
(01-08-2012, 21:12)iAegle Wrote:
(01-08-2012, 21:12)Pozzuh Wrote: Why do you never test your plugins

Ohh thats simple, because I can't :p

why cant you

No game/server

Why don't you install it
[Image: MaEIQ.png]
Reply

#10
This anti flood thingy was always pissing me off, but still nice work.
This anti flood thingy was always pissing me off, but still nice work.
[Image: lQDUjba.jpg]
Reply



Possibly Related Threads…
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 3,905 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 4,377 11-08-2013, 19:13
Last Post: clemi555
  [Release] iSnipe anti hardscope mutant 0 3,263 11-06-2013, 11:27
Last Post: mutant
  [Release] Bunker Plugin 1.3 archit 68 38,483 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 5,278 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 4,662 10-19-2013, 06:59
Last Post: iRoNinja
  Need An Anti Hack Manuadminmod worldclass 2 3,504 10-14-2013, 09:57
Last Post: d0h!
  [Release] Yurio Map Plugin Yurio 101 57,922 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 17,446 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 2,537 09-13-2013, 09:31
Last Post: Hallla

Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum Powered By MyBB, Theme by © 2002-2024 Melroy van den Berg.