Advertisement
Guest User

Untitled

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