• 3 Vote(s) - 4.67 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Release AntiCamp Plugin
#1
A plugin that warns if player does not move a specific distance within a specific time.

Requires:
@Nukem's Server Addon v1.320 or higher

sv_config.ini entries:
Code:
[AntiCamp]
//Minimal distance
Distance=5
//Within this time
Time=4
//Message when someone is camping, use {0} for name, example: {0} stop camping!
Message=
//After how many warnings is the AdditionalAction executed
Warnings=2
//Additional action after too many warnings, kickClient, dropClient, tempBanClient, banClient
AdditionalAction=
//Plugin enabled, disabled
Enabled=1

Chat commands:
Code:
//Enable plugin
!camp 1
//Disable plugin
!camp 0

Thanks to @makavel for idea and testing

Source code:
CSHARP Code
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Addon;
  5.  
  6. namespace AntiCamp
  7. {
  8. public class Class1 : CPlugin
  9. {
  10. bool PluginEnabled = true;
  11. float distance = 5;
  12. uint time = 4;
  13. uint timer = 16;
  14. byte warnings = 2;
  15. string message = string.Empty;
  16. string AdditionalAction = string.Empty;
  17. // ClientNum, Origin
  18. Dictionary<int, Vector> Players = new Dictionary<int, Vector>();
  19. // ClientNum, Number of warnings
  20. Dictionary<int, uint> WarningDic = new Dictionary<int, uint>();
  21. // ClientNum, Ignores
  22. Dictionary<int, uint> IgnoreList = new Dictionary<int, uint>();
  23.  
  24. public override void OnServerLoad()
  25. {
  26. ServerPrint("\n AntiCamp loaded \n Author: zxz0O0 \n Idea and testing: Makavel \n Thanks to Nukem, Jariz and Pozzuh\n");
  27. ServerPrint(" youtube.com/zxz0O0 \n itsmods.com\n");
  28.  
  29. try
  30. {
  31. distance = float.Parse(GetServerCFG("AntiCamp", "Distance", "5"));
  32. time = uint.Parse(GetServerCFG("AntiCamp", "Time", "4"));
  33. timer = 4 * time;
  34. message = GetServerCFG("AntiCamp", "Message", string.Empty);
  35. AdditionalAction = GetServerCFG("AntiCamp", "AdditionalAction", string.Empty);
  36. warnings = byte.Parse(GetServerCFG("AntiCamp", "Warnings", "2"));
  37. if (GetServerCFG("AntiCamp", "Enabled", "1") == "0")
  38. PluginEnabled = false;
  39. }
  40. catch (Exception e)
  41. {
  42. ServerPrint(e.ToString());
  43. }
  44. }
  45.  
  46. public override void OnPlayerChangeWeapon(ServerClient Client, int WeaponID)
  47. {
  48. if (WeaponID == GetWeapon("briefcase_bomb_mp"))
  49. {
  50. if(!IgnoreList.ContainsKey(Client.ClientNum))
  51. IgnoreList.Add(Client.ClientNum, 1);
  52. else if (IgnoreList[Client.ClientNum]<2)
  53. IgnoreList[Client.ClientNum]++;
  54. }
  55. }
  56.  
  57. public override void OnPlayerUse(ServerClient Client)
  58. {
  59. if (!IgnoreList.ContainsKey(Client.ClientNum))
  60. IgnoreList.Add(Client.ClientNum, 1);
  61. else if (IgnoreList[Client.ClientNum] < 2)
  62. IgnoreList[Client.ClientNum]++;
  63. }
  64.  
  65. public override void OnPlayerSpawned(ServerClient Client)
  66. {
  67. if (!IgnoreList.ContainsKey(Client.ClientNum))
  68. IgnoreList.Add(Client.ClientNum, 2);
  69. else
  70. IgnoreList[Client.ClientNum] = 2;
  71. }
  72.  
  73. //4FPS
  74. public override void OnAddonFrame()
  75. {
  76. if (PluginEnabled)
  77. {
  78. timer--;
  79. if (timer == 0)
  80. {
  81. timer = 4 * time;
  82. foreach (ServerClient c in GetClients())
  83. {
  84. if (c.Ping == 999)
  85. continue;
  86. if (c.Team == Teams.Spectator)
  87. continue;
  88. if (CheckContinue(c.ClientNum))
  89. continue;
  90. if (!Players.ContainsKey(c.ClientNum))
  91. Players.Add(c.ClientNum, new Vector(c.OriginX, c.OriginY, c.OriginZ));
  92. else if (CalculateDistance(c.ClientNum) < distance)
  93. {
  94. if (!string.IsNullOrEmpty(message))
  95. ServerSay(string.Format(message, c.Name), true);
  96. if (!string.IsNullOrEmpty(AdditionalAction))
  97. {
  98. if (!WarningDic.ContainsKey(c.ClientNum))
  99. WarningDic.Add(c.ClientNum, 1);
  100. else
  101. WarningDic[c.ClientNum]++;
  102.  
  103. if (WarningDic[c.ClientNum] > warnings)
  104. ServerCommand(AdditionalAction + " " + c.ClientNum);
  105. }
  106. }
  107. }
  108. }
  109. }
  110. }
  111.  
  112. public override ChatType OnSay(string Message, ServerClient Client)
  113. {
  114. if (Message == "!camp 1")
  115. {
  116. TellClient(Client.ClientNum, "AntiCamp enabled", true);
  117. PluginEnabled = true;
  118. return ChatType.ChatNone;
  119. }
  120. else if (Message == "!camp 0")
  121. {
  122. TellClient(Client.ClientNum, "AntiCamp disabled", true);
  123. PluginEnabled = false;
  124. Players.Clear();
  125. WarningDic.Clear();
  126. return ChatType.ChatNone;
  127. }
  128. return ChatType.ChatContinue;
  129. }
  130.  
  131. private float CalculateDistance(int ClientNum)
  132. {
  133. try
  134. {
  135. ServerClient c = GetClient(ClientNum);
  136. Vector PlayerVec = Players[ClientNum];
  137. float x = PlayerVec.X - c.OriginX;
  138. x *= x;
  139. float y = PlayerVec.Y - c.OriginY;
  140. y *= y;
  141. float z = PlayerVec.Z - c.OriginZ;
  142. z *= z;
  143. Players[ClientNum] = new Vector(c.OriginX, c.OriginY, c.OriginZ);
  144. return (float)Math.Sqrt(x + y + z);
  145. }
  146. catch (Exception e)
  147. {
  148. ServerPrint(e.ToString());
  149. }
  150. return 0;
  151. }
  152.  
  153. private bool CheckContinue(int ClientNum)
  154. {
  155. if (IgnoreList.ContainsKey(ClientNum) && IgnoreList[ClientNum] > 0)
  156. {
  157. IgnoreList[ClientNum]--;
  158. return true;
  159. }
  160.  
  161. return false;
  162. }
  163.  
  164. public override void OnPlayerDisconnect(ServerClient Client)
  165. {
  166. if (Players.ContainsKey(Client.ClientNum))
  167. Players.Remove(Client.ClientNum);
  168. if (WarningDic.ContainsKey(Client.ClientNum))
  169. WarningDic.Remove(Client.ClientNum);
  170. if (IgnoreList.ContainsKey(Client.ClientNum))
  171. IgnoreList.Remove(Client.ClientNum);
  172. }
  173. }
  174. }


Attached Files
.zip   AntiCamp.zip (Size: 3.5 KB / Downloads: 1,217)
[Image: azuw.jpg]
[-] The following 11 users say Thank You to zxz0O0 for this post:
  • amirdj, Arteq, Canta, Casper, DidUknowiPwn, iAegle, itsmods.com76, jiuweiljp, kokole, narkos, Pozzuh
  Reply
#2
Fuu Anticamp.... Fuu Angry
[Image: veovuq.png]
[-] The following 3 users say Thank You to Yamato for this post:
  • estebespt, kokole, The Clay Man
  Reply
#3
Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu Fuu
[-] The following 4 users say Thank You to The Clay Man for this post:
  • estebespt, FluffyGrenade, kokole, Yamato
Away
  Reply
#4
oma faggots can't camp anymore booohoooh
[Image: MaEIQ.png]
  Reply
#5
what is the range of the distance?
i presume the time is in seconds?
[Image: b_560_95_1.png]


[Image: b_560_95_1.png]

  Reply
#6
(05-19-2012, 13:25)hillbilly Wrote: what is the range of the distance?
i presume the time is in seconds?

Time is seconds, distance, well I don't know what CoD uses, I suppose it's feets. In my plugin distance is a float so the range is ±1.5e−45 to ±3.4e38
[Image: azuw.jpg]
  Reply
#7
You are great zxz0O0! Smile

Someone can tell me the difference between:
Kickclient
Dropclient

Another question:
The time camping, when you also account Turret, AC130, etc?
[Image: b_560_95_1.png]
  Reply
#8
(05-19-2012, 18:03)Canta Wrote: You are great zxz0O0! Smile

Someone can tell me the difference between:
Kickclient
Dropclient

Another question:
The time camping, when you also account Turret, AC130, etc?

KickClient is like a tempBan. DropClient just kicks the client :S

Yes, though when you are 'using' something you get ignored for one cycle (planting, taking care package, using sentry)
[Image: azuw.jpg]
[-] The following 2 users say Thank You to zxz0O0 for this post:
  • AboAlwe, Canta
  Reply
#9
@zxz0O0 is now a Company of Heroes Camper Troll
[Image: veovuq.png]
[-] The following 3 users say Thank You to Yamato for this post:
  • barata, Canta, zxz0O0
  Reply
#10
I was flying with "Reaper" and expelled me from the server with this message:

G_GetPlayerViewDrigin():Couldn't Find

edit:
The full server stopped working. Console.log:
[01:01:16] System.NullReferenceException: Object reference not set to an instance of an object.

at AntiCamp.Class1.OnAddonFrame()

at Addon.PluginCode.TriggerAddonFrame()
[Image: b_560_95_1.png]
  Reply


Possibly Related Threads...
Thread Author Replies Views Last Post
Wink Plugin with !ban !kick and !tampban clemi555 3 1,018 11-09-2013, 09:21
Last Post: clemi555
  AntiNoScope Plugin clemi555 5 1,002 11-08-2013, 19:13
Last Post: clemi555
  [Release] Bunker Plugin 1.3 archit 68 12,708 10-30-2013, 11:59
Last Post: clacki
  Help Modifying plugin maverigh 5 1,289 10-19-2013, 10:29
Last Post: Nekochan
Shocked [Request] Switch plugin axel-le-meilleur 6 1,134 10-19-2013, 06:59
Last Post: iRoNinja
  [Release] Yurio Map Plugin Yurio 101 21,875 09-26-2013, 13:38
Last Post: First_Semyon
Brick [Release] v1.1 ChangeMap/NextMap Plugin without any configuration milchshake 23 7,089 09-23-2013, 13:18
Last Post: SgtLegend
  Help !say Plugin (like the !say from GodPlugin) Hallla 0 718 09-13-2013, 09:31
Last Post: Hallla
Rainbow [Release] MW3: Random Weapon Plugin V1 Nekochan 50 10,669 09-11-2013, 15:11
Last Post: EnVi Sweden Rocks
  Search Plugin Fluid Killcam N3xT_974 1 851 09-10-2013, 20:27
Last Post: Nekochan

Forum Jump:


Users browsing this thread: 1 Guest(s)