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

Problems with dispatchCommand()

Discussion in 'Development' started by M4nt0s, Aug 19, 2018.

  1. M4nt0s

    M4nt0s Spider Jockey

    Messages:
    31
    GitHub:
    M4nt0s
    I try to run a command as player when a sign get clicked. Different IDEs show me no errors.

    Error message: Server thread/CRITICAL ParseError: "syntax error, unexpected '"minereset1"' (T_CONSTANT_ENCAPSED_STRING), expecting ',' or ')'" (EXCEPTION) on line 67


    PHP:
    public function onInteract(PlayerInteractEvent $event){
        
    $block $event->getBlock();
        
    $player $event->getPlayer();
        
    $tile =
        
    $player->getLevel()->getTile($block);
        if(
    $tile instanceof Sign){
            
    $text $tile->getText();
            
    $line1 $tile->getLine(0);
            if(
    $line1 == "Mine1"){
    Line 67-> $this->getServer()->dispatchCommand($event->getPlayer(), "mine reset 1");
                
                }
                
                }
                
                }
    Thanks for future help.
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Perhaps an weird charset? Try rewriting the code by hand and see if it works.
     
  3. Zach1603

    Zach1603 Spider Jockey

    Messages:
    27
    GitHub:
    zedstar16
    Try:
    PHP:
    public function onInteract(PlayerInteractEvent $event){
        
    $block $event->getBlock();
        
    $player $event->getPlayer();
        
    $tile =
        
    $player->getLevel()->getTile($block);
        if(
    $tile instanceof Sign){
            
    $text $tile->getText();
            
    $line1 $tile->getLine(0);
            if(
    $line1 == "Mine1"){
    Line 67-> $this->getServer()->dispatchCommand($player"mine reset 1");
               
                }
               
                }
               
                }
    The error might have been caused because it was expecting a ; at the end of $event->getPlayer() where instead there was a ,
     
  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.