Featured Replies
Сейчас на странице 0
- Нет пользователей, просматривающих эту страницу
A better way to browse. Learn more.
A full-screen app on your home screen with push notifications, badges and more.
Используя этот сайт, вы соглашаетесь Условия использования.
I got a request from =[DNS]=WildCat to fix some issues with the original AntiCamp which I did. As I think it may be also useful for other people I release the source here.
Changes I did to the original AntiCamp:
- Add check if player is using killstreak weapon
- Add check if player is using sentry turret
- Add customizable distance
- Add customizable time for checking distance
- Add customizable option for max warnings -> when the player reaches maximum he will suicide
To use the custom option you add in your server config:
Change the above values to your need.
Source code:
using System; using System.Collections.Generic; using System.Linq; using System.Text; using InfinityScript; namespace InfinityScript.Examples { public class AntiCamp : BaseScript { private bool _donePrematch = false; private List _safeTriggers = new List(); private int Distance = 50; private int CheckTime = 4000; private int[] Warnings = new int[18]; private int MaxWarnings = 2; private static bool isKillstreakWep(string wep) { if (wep.Contains("ac130")) return true; if (wep.Contains("remote")) return true; if (wep.Contains("minigun")) return true; return false; } public AntiCamp() { Call("setdvarifuninitialized", "scr_ac_time", 4000); Call("setdvarifuninitialized", "scr_ac_distance", 50); Call("setdvarifuninitialized", "scr_ac_maxwarnings", 2); Distance = Call("getdvarint", "scr_ac_distance"); CheckTime = Call("getdvarint", "scr_ac_time"); MaxWarnings = Call("getdvarint", "scr_ac_maxwarnings"); if (CheckTime < 500) CheckTime = 500; var gameType = Call("getDvar", "g_gametype").ToLower(); for (int i = 0; i < 2048; i++) { var entity = Call("getEntByNum", i); if (entity != null) { var targetname = entity.GetField("targetname"); if (gameType == "dom") { if (targetname == "flag_primary" || targetname == "flag_secondary") { _safeTriggers.Add(entity); } } else if (gameType == "koth") { if (targetname == "radiotrigger") { _safeTriggers.Add(entity); } } } } // only trigger anticamp after the game started OnNotify("prematch_done", () => { _donePrematch = true; }); // don't trigger anticamp after the game ended OnNotify("game_over", () => { _donePrematch = false; }); PlayerConnecting += new Action(entity => { // bombsite using entity.SetField("ac_using", 0); //using remote entity.SetField("ac_remote", 0); entity.OnNotify("use_hold", player => { player.SetField("ac_using", 1); }); entity.OnNotify("done_using", player => { player.SetField("ac_using", 0); }); entity.OnNotify("using_remote", player => { player.SetField("ac_remote", 1); }); entity.OnNotify("stopped_using_remote", player => { player.SetField("ac_remote", 0); }); //entity.OnInterval(4000, player => entity.OnInterval(CheckTime, player => { int entNum = player.Call("getentitynumber"); if (!player.IsAlive) { goto _Reset; } if (!_donePrematch) { goto _Reset; } if (player.GetField("ac_using") != 0) { goto _Reset; } if (player.GetField("ac_remote") != 0) { goto _Reset; } if (isKillstreakWep(player.CurrentWeapon)) goto _Reset; foreach (var safeEntity in _safeTriggers) { if (player.Call("istouching", safeEntity) != 0) { Log.Write(LogLevel.Trace, "touching safe entity"); goto _Reset; } } if (player.Call("istalking") != 0) { Log.Write(LogLevel.Trace, "talking"); goto _Reset; } if (player.Call("isusingturret") != 0) { goto _Reset; } if (player.HasField("ac_lastPos")) { var lastPos = player.GetField("ac_lastPos"); //why no height difference? //if (lastPos.DistanceTo2D(player.Origin) < 50) if (lastPos.DistanceTo(player.Origin) < Distance) { player.Call("iprintlnbold", "You will be killed if you do not move."); Warnings[entNum]++; if (Warnings[entNum] >= MaxWarnings) { player.Call("suicide"); goto _Reset; } } } goto _NoReset; _Reset: Warnings[entNum] = 0; _NoReset: player.SetField("ac_lastPos", player.Origin); return true; }); }); } } }Credits to NTAuthority or whoever made the original AntiCamp example.