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

Anti-Reach help?!?!?!?!?!

Discussion in 'Development' started by Vaxrp, Oct 24, 2017.

  1. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Hey, so I am a decently new plygin maker. I know the basics have made a couple super simple plugins for my server but I want to start on a “Anti-Reach” Project where it notifies me when someone is hitting someone from more than a certain amount if blocks away. I dont know how to start at all. You dont have to baby me and give me the codes if you dont want maybe just explain what I need to use and what functions. Thanks guys hopefully you guys can help me
     
  2. VCraft

    VCraft Witch

    Messages:
    60
    GitHub:
    VCraftMCPE
    entity damage.
     
  3. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    Dont be so basic. I dont even know what you mean by that. I mean thanks but can you explain it a bit more? Like what I have to make the event do
     
  4. VCraft

    VCraft Witch

    Messages:
    60
    GitHub:
    VCraftMCPE
    PHP:
    public function HIT(EntityDamageEvent $hit) {
    if(
    $hit instanceof EntityDamageByEntityEvent) {
    if((
    $hit->getEntity() instanceof Player) and ($hit->getDamager() instanceof Player)) {
    //code
    }
    }
    }
     
  5. Vaxrp

    Vaxrp Witch

    Messages:
    73
    GitHub:
    Vaxrp
    How can I set the amount of blocks it can hit before they get kicked
     
  6. VCraft

    VCraft Witch

    Messages:
    60
    GitHub:
    VCraftMCPE
    PHP:
    public $hited = [];
    onDamage(){
    $this->hited[$p] = true;
    }
    if(isset(
    $this->hited[$p])){
       
    //ban him
    }
    something like that
     
    Last edited: Oct 24, 2017
    Vaxrp likes this.
  7. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
        public function onDamage(EntityDamageEvent $event) {
            if(
    $event instanceof EntityDamageByEntityEvent) {
                
    $damager $event->getDamager();
                
    $damaged $event->getEntity();
                if(
    $damaged instanceof Player and $damager instanceof Player) {
                    
    $blocks 6// max distance allowed (can be float or int)
                    
    if(ceil($damager->distance($damaged)) > $blocks) {
                        
    $damager->kick("hacks"false);
                    }
                }
            }
        }
     
    Vaxrp likes this.
  8. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    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!");
                }
            }
        }
    }
     
    Vaxrp likes this.
  9. Rateek

    Rateek Silverfish

    Messages:
    15
    GitHub:
    RATEEK
    For what you do anticheats with the events you will have falses logs, The best anticheats it is to do them with the packets (DataPacket) and all ...
     
    Vaxrp likes this.
  10. VCraft

    VCraft Witch

    Messages:
    60
    GitHub:
    VCraftMCPE
    oh sorry i didnt understand that u wanted the distance
     
  11. friscowz

    friscowz Baby Zombie Ban Evader Banned

    Messages:
    128
    GitHub:
    friscowzmcpe
    What are you saying ?? did u really test both of them at the same time before spreading probably fake informations ?
     
    jasonwynn10 and Marabou like this.
  12. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    true.
     
    friscowz likes this.
  13. Marabou

    Marabou Baby Zombie

    Messages:
    137
    GitHub:
    wiligangster
    your information is false + lagg.
     
  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.