1. The forums will be archived and moved to a read only mode in about 2 weeks (mid march).

Tutorial How to make an Anti-Reach.

Discussion in 'Resources' started by friscowz, Oct 24, 2017.

  1. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    So basiclly what we are going to do is to check if both of the entities are players or not, then we are going to calculate the Distance between the two players using the Vector3 function called distance(), i've tested the maximum amount of Normal reach and it was 3.9, so we are going to cancel the Hits if the Distance between the two players is higher than 3.9!
    PHP:
    /**
    * @param EntityDamageEvent $event
    */
    public function onDamage(EntityDamageEvent $event)
    {
        
    $entity $event->getEntity();
        if(
    $event instanceof EntityDamageByEntityEvent and $entity instanceof Player){
            
    $damager $event->getDamager();
            if(
    $damager instanceof Player){
                if(
    $damager->getGamemode() == Player::CREATIVE or $damager->getGamemode() == Player::SPECTATOR) return;
                
    $distance $damager->distance($entity);
                
    $max 3.9//The Maximum amount of reach that i got when i was legit.
                
    if($distance $max){
                    
    $event->setCancelled(true);
                    
    $this->getLogger()->debug(TextFormat::RED $damager->getName() . " got " $distance " of reach!");
                }
            }
        }
    }
     
    MasterPHP and Ant like this.
  2. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    please note that doing that is bad, especially for laggy players or servers
    suggest adding tolerance
    suggest adding suspicious tick to prevent false flag
     
  3. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    actually i tested the reach with a Laggy connection and it didn't mess with the Reach distance, didn't try with a laggy server but this code just cancel the hits so it's okay
     
  4. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    This will cause a bug with bows where they won't take damage if the distance is greater than your maximum reach.

    I'd add a cause check to prevent this from happening.
     
  5. MasterPHP

    MasterPHP Spider

    Messages:
    6
    Could Set Items
    Example: Items of PvP, Swords, Axes, Hand, among other Items.
    It will be ?
    I'm a newbie !!
     
  6. MasterPHP

    MasterPHP Spider

    Messages:
    6
    Yes it is very easy to check the items
     
  7. xZeroMCPE

    xZeroMCPE Witch

    Messages:
    67
    GitHub:
    xZeroMCPE
    You can't actually make a 100% efficient anti reach, nor hacker free server.

    All this is doing is adding more limited factors, but can always affect legit players.

    What if Bobby combo BOB, hitting BOB multiple times and the last hit was from far away. Wouldn't this affect such matters?
    There's always a scene where it would also affect the real players.

    But anyhow, you guys can use the method for monitoring, but shouldn't be canceled.
     
    HippoBaguette likes this.
  8. Thunder33345

    Thunder33345 Moderator Staff Member

    Messages:
    2,137
    GitHub:
    Thunder33345
    that's why there should be more threshold and calculated, ex bobby always hit BOB at a far range for >90% of the time
     
    Irish likes this.
  9. RJoLe

    RJoLe Creeper

    Messages:
    5
    Thankssss :V
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.