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

How to send command to player who clicked on another player?

Discussion in 'Development' started by LewBr, Oct 22, 2017.

  1. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    How to send a command or event to the player who clicked on another player? Maybe DataPacketReceiveEvent ,can send me an example code?
     
  2. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    PHP:
    public function onInteract(EntityDamageEvent $event) {
        if(
    $event instanceof EntityDamageByEntityEvent and $event->getEntity() instanceof Player and $event->getDamager() instanceof Player) {
            
    $this->getServer()->dispatchCommand($event->getPlayer(), "command to run here");
        }
    }
     
  3. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    Can you give me an example whit DataPacketSend? because i have whit EntityDamage cancelled on the world.
     
  4. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
    The event function should still be called even if the event is cancelled
     
  5. LewBr

    LewBr Zombie

    Messages:
    385
    GitHub:
    lewbr
    It has an method to cancel players to pvp in each world and when click send this command?
     
  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.