Advertisement
Guest User

Untitled

a guest
Jul 21st, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 7.55 KB | None | 0 0
  1.         //PMC - system {
  2.  
  3.         public PlayerLocation LastOnGroundLocation = null;
  4.  
  5.         public bool СheckerIgnore = false;//recommended - disable
  6.         public int UnCheckedTicks = 0;
  7.         public int UnCheckedPackets = 0;
  8.  
  9.         public const double MADiffD = 1.3;//MaxAllowedDifferenceDefault  //recommended 1.3
  10.         public double MaxAllowedDifference = MADiffD;
  11.  
  12.         public const double MADistD = 0.615;//MaxAllowedDistanceDefault  //recommended 0.615
  13.         public double PermissibleDifference = 0.025;//recommended 0.025
  14.         public double MaxAllowedDistance = MADistD;
  15.         public int MaxCountOfSpeeding = 5;//recommended 3 - 5 //0 - disabled
  16.  
  17.         public bool EnabledKicksBySpeeding = true;//recommended - enable
  18.         public int CountOfSpeeding = 0;
  19.  
  20.         public double maxdist = 0;
  21.  
  22.         public void UpdateAllowedLocation(PlayerLocation newLocation, int unCheckedTicks = 0, int unCheckedPackets = 0)//обязательно выполнять после любого перемещения игрока!!!
  23.         {
  24.             LastOnGroundLocation = newLocation;
  25.             if (unCheckedTicks > 0)
  26.                 UnCheckedTicks = unCheckedTicks;
  27.             if (unCheckedPackets > 0)
  28.                 UnCheckedPackets = unCheckedPackets;
  29.         }
  30.  
  31.         public double MathMaxSpeed(Speed effect)
  32.         {
  33.             if (effect.Level <= 0)
  34.                 return MADistD;
  35.             else
  36.                 return MADistD * Math.Pow(1.2, effect.Level) + 0.1;
  37.         }
  38.  
  39.         public double MathMaxJamp(JumpBoost effect)
  40.         {
  41.             if (effect.Level <= 0)
  42.                 return MADiffD;
  43.             else
  44.                 return MADiffD + (0.5 * effect.Level);
  45.         }
  46.  
  47.         public override void OnTick()
  48.         {
  49.             if (UnCheckedTicks > 0)
  50.                 UnCheckedTicks--;
  51.             base.OnTick();
  52.         }
  53.  
  54.         protected override bool AcceptPlayerMove(McpeMovePlayer message, bool isOnGround, bool isFlyingHorizontally)
  55.         {
  56.             PlayerLocation newLocation = new PlayerLocation(message.x, message.y, message.z, message.headYaw, message.yaw, message.pitch);
  57.             if (isOnGround)
  58.             {
  59.                 LastOnGroundLocation = newLocation;
  60.  
  61.                 if (!IsSpectator && !IsFlying && !СheckerIgnore && UnCheckedPackets <= 0 && UnCheckedTicks <= 0)
  62.                 {
  63.                     if (Effects.ContainsKey(EffectType.Speed))
  64.                         MaxAllowedDistance = MathMaxSpeed(Effects[EffectType.Speed] as Speed);
  65.                     else if (MaxAllowedDistance != MADistD)
  66.                         MaxAllowedDistance = MADistD;
  67.  
  68.                     //if (KnownPosition.FlatDistanceTo(newLocation) > maxdist)
  69.                     //{
  70.                     //    Console.WriteLine($"{KnownPosition.FlatDistanceTo(newLocation)}    {Username}");
  71.                     //    maxdist = KnownPosition.FlatDistanceTo(newLocation);
  72.                     //}
  73.  
  74.                     double distance = KnownPosition.FlatDistanceTo(newLocation);
  75.                     if (distance > MaxAllowedDistance)
  76.                     {
  77.                         if (Annihilation.Debug) Level.BroadcastMessage($"{CountOfSpeeding}  {KnownPosition.FlatDistanceTo(newLocation)}   {Username}");
  78.                         Teleport(KnownPosition);
  79.                         if (distance - MaxAllowedDistance > PermissibleDifference)
  80.                         {
  81.                             Level.BroadcastMessage($"§8[§2PM§cC§8]§7We detected §2SpeedHack §7from you. Please disable it, if it's really so!");
  82.                             if (MaxCountOfSpeeding > 0)
  83.                                 CountOfSpeeding++;
  84.                         }
  85.                         if (CountOfSpeeding >= MaxCountOfSpeeding)
  86.                         {
  87.                             Disconnect("§8[§2PM§cC§8]§7Speeding is not allowed.\n§8[§2PM§cC§8]§7We detected §2SpeedHack §7from you. Please disable it, if it's really so!   §eError code: §4#375.4!");
  88.                             //Level.BroadcastMessage(Username + " возможно читер!!!");
  89.                             return true;
  90.                         }
  91.                     }
  92.                 }
  93.             }
  94.             else
  95.             {
  96.                 if (!IsSpectator && !IsFlying && !СheckerIgnore && UnCheckedPackets <= 0 && UnCheckedTicks <= 0)
  97.                 {
  98.                     double distance = KnownPosition.FlatDistanceTo(newLocation);
  99.                     if (distance > MaxAllowedDistance + 0.1)
  100.                     {
  101.                         Teleport(KnownPosition);
  102.                         if (distance - MaxAllowedDistance + 0.1 > PermissibleDifference)
  103.                         {
  104.                             Level.BroadcastMessage($"§8[§2PM§cC§8]§7We detected §2Flight §7from you. Please disable it, if it's really so!");
  105.                             if (MaxCountOfSpeeding > 0)
  106.                                 CountOfSpeeding+=2;
  107.                         }
  108.                         if (CountOfSpeeding >= MaxCountOfSpeeding)
  109.                         {
  110.                             Disconnect("§8[§2PM§cC§8]§7Flight is not allowed.\n§8[§2PM§cC§8]§7We detected §2Flight §7from you. Please disable it, if it's really so!   §eError code: §4#375.2!");
  111.                             //Level.BroadcastMessage(Username + " возможно читер!!!");
  112.                             return true;
  113.                         }
  114.                     }
  115.  
  116.                     if (isFlyingHorizontally)
  117.                     {
  118.                         if (message.y <= 256)
  119.                         {
  120.                             Disconnect("§8[§2PM§cC§8]§7Flight is not allowed.\n§8[§2PM§cC§8]§7We detected §2Flight §7from you. Please disable it, if it's really so!   §eError code: §4#375.1!");
  121.                             //Level.BroadcastMessage(Username + " возможно читер!!!");
  122.                             return true;
  123.                         }
  124.                     }
  125.  
  126.                     if (newLocation.Y > LastOnGroundLocation.Y)
  127.                     {
  128.                         if (newLocation.Y - LastOnGroundLocation.Y > maxdist)
  129.                         {
  130.                             Console.WriteLine($"{newLocation.Y - LastOnGroundLocation.Y}    {Username}");
  131.                             maxdist = newLocation.Y - LastOnGroundLocation.Y;
  132.                         }
  133.                         //Console.WriteLine($"{newLocation.Y - LastOnGroundLocation.Y}   {Username}");
  134.                         if (Effects.ContainsKey(EffectType.JumpBoost))
  135.                             MaxAllowedDifference = MathMaxJamp(Effects[EffectType.JumpBoost] as JumpBoost);
  136.                         else if (MaxAllowedDifference != MADiffD)
  137.                             MaxAllowedDifference = MADiffD;
  138.                         if (newLocation.Y - LastOnGroundLocation.Y > MaxAllowedDifference)
  139.                         {
  140.                             Disconnect("§8[§2PM§cC§8]§7Flight and high jumping is not allowed.\n§8[§2PM§cC§8]§7We detected §2Flight §7or §2HighJumping §7from you. Please disable it, if it's really so!   §eError code: §4#375.3!");
  141.                         }
  142.                     }
  143.                     else
  144.                         LastOnGroundLocation = newLocation;
  145.                 }
  146.             }
  147.             if (UnCheckedPackets > 0)
  148.                 UnCheckedPackets--;
  149.             return base.AcceptPlayerMove(message, isOnGround, isFlyingHorizontally);
  150.         }
  151.  
  152.         //} PMC - system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement