Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //PMC - system {
- public PlayerLocation LastOnGroundLocation = null;
- public bool СheckerIgnore = false;//recommended - disable
- public int UnCheckedTicks = 0;
- public int UnCheckedPackets = 0;
- public const double MADiffD = 1.3;//MaxAllowedDifferenceDefault //recommended 1.3
- public double MaxAllowedDifference = MADiffD;
- public const double MADistD = 0.615;//MaxAllowedDistanceDefault //recommended 0.615
- public double PermissibleDifference = 0.025;//recommended 0.025
- public double MaxAllowedDistance = MADistD;
- public int MaxCountOfSpeeding = 5;//recommended 3 - 5 //0 - disabled
- public bool EnabledKicksBySpeeding = true;//recommended - enable
- public int CountOfSpeeding = 0;
- public double maxdist = 0;
- public void UpdateAllowedLocation(PlayerLocation newLocation, int unCheckedTicks = 0, int unCheckedPackets = 0)//обязательно выполнять после любого перемещения игрока!!!
- {
- LastOnGroundLocation = newLocation;
- if (unCheckedTicks > 0)
- UnCheckedTicks = unCheckedTicks;
- if (unCheckedPackets > 0)
- UnCheckedPackets = unCheckedPackets;
- }
- public double MathMaxSpeed(Speed effect)
- {
- if (effect.Level <= 0)
- return MADistD;
- else
- return MADistD * Math.Pow(1.2, effect.Level) + 0.1;
- }
- public double MathMaxJamp(JumpBoost effect)
- {
- if (effect.Level <= 0)
- return MADiffD;
- else
- return MADiffD + (0.5 * effect.Level);
- }
- public override void OnTick()
- {
- if (UnCheckedTicks > 0)
- UnCheckedTicks--;
- base.OnTick();
- }
- protected override bool AcceptPlayerMove(McpeMovePlayer message, bool isOnGround, bool isFlyingHorizontally)
- {
- PlayerLocation newLocation = new PlayerLocation(message.x, message.y, message.z, message.headYaw, message.yaw, message.pitch);
- if (isOnGround)
- {
- LastOnGroundLocation = newLocation;
- if (!IsSpectator && !IsFlying && !СheckerIgnore && UnCheckedPackets <= 0 && UnCheckedTicks <= 0)
- {
- if (Effects.ContainsKey(EffectType.Speed))
- MaxAllowedDistance = MathMaxSpeed(Effects[EffectType.Speed] as Speed);
- else if (MaxAllowedDistance != MADistD)
- MaxAllowedDistance = MADistD;
- //if (KnownPosition.FlatDistanceTo(newLocation) > maxdist)
- //{
- // Console.WriteLine($"{KnownPosition.FlatDistanceTo(newLocation)} {Username}");
- // maxdist = KnownPosition.FlatDistanceTo(newLocation);
- //}
- double distance = KnownPosition.FlatDistanceTo(newLocation);
- if (distance > MaxAllowedDistance)
- {
- if (Annihilation.Debug) Level.BroadcastMessage($"{CountOfSpeeding} {KnownPosition.FlatDistanceTo(newLocation)} {Username}");
- Teleport(KnownPosition);
- if (distance - MaxAllowedDistance > PermissibleDifference)
- {
- Level.BroadcastMessage($"§8[§2PM§cC§8]§7We detected §2SpeedHack §7from you. Please disable it, if it's really so!");
- if (MaxCountOfSpeeding > 0)
- CountOfSpeeding++;
- }
- if (CountOfSpeeding >= MaxCountOfSpeeding)
- {
- 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!");
- //Level.BroadcastMessage(Username + " возможно читер!!!");
- return true;
- }
- }
- }
- }
- else
- {
- if (!IsSpectator && !IsFlying && !СheckerIgnore && UnCheckedPackets <= 0 && UnCheckedTicks <= 0)
- {
- double distance = KnownPosition.FlatDistanceTo(newLocation);
- if (distance > MaxAllowedDistance + 0.1)
- {
- Teleport(KnownPosition);
- if (distance - MaxAllowedDistance + 0.1 > PermissibleDifference)
- {
- Level.BroadcastMessage($"§8[§2PM§cC§8]§7We detected §2Flight §7from you. Please disable it, if it's really so!");
- if (MaxCountOfSpeeding > 0)
- CountOfSpeeding+=2;
- }
- if (CountOfSpeeding >= MaxCountOfSpeeding)
- {
- 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!");
- //Level.BroadcastMessage(Username + " возможно читер!!!");
- return true;
- }
- }
- if (isFlyingHorizontally)
- {
- if (message.y <= 256)
- {
- 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!");
- //Level.BroadcastMessage(Username + " возможно читер!!!");
- return true;
- }
- }
- if (newLocation.Y > LastOnGroundLocation.Y)
- {
- if (newLocation.Y - LastOnGroundLocation.Y > maxdist)
- {
- Console.WriteLine($"{newLocation.Y - LastOnGroundLocation.Y} {Username}");
- maxdist = newLocation.Y - LastOnGroundLocation.Y;
- }
- //Console.WriteLine($"{newLocation.Y - LastOnGroundLocation.Y} {Username}");
- if (Effects.ContainsKey(EffectType.JumpBoost))
- MaxAllowedDifference = MathMaxJamp(Effects[EffectType.JumpBoost] as JumpBoost);
- else if (MaxAllowedDifference != MADiffD)
- MaxAllowedDifference = MADiffD;
- if (newLocation.Y - LastOnGroundLocation.Y > MaxAllowedDifference)
- {
- 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!");
- }
- }
- else
- LastOnGroundLocation = newLocation;
- }
- }
- if (UnCheckedPackets > 0)
- UnCheckedPackets--;
- return base.AcceptPlayerMove(message, isOnGround, isFlyingHorizontally);
- }
- //} PMC - system
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement