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

Is there any way to send a message as another player?

Discussion in 'Plugin Help' started by Todo56, Sep 14, 2019.

  1. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    I'm trying to make a plugin to send a message as another player, is there any way to so it?
     
  2. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    yes
     
  3. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    How?
     
  4. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Im on mobile so if this doesn't work o well xD but here
    PHP:
    $player $this->getServer()->getPlayer(array_shift($args));
                    if (
    $player instanceof Player) {
                        
    $this->getServer()->dispatchCommand($playertrim(implode(" "$args)));
                        return 
    true;
                    } else {
                        
    $sender->sendMessage($this->prefix "Player not found.");
                        return 
    true;
                    }
     
  5. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    So $this->getServer()->dispatchCommand($player, trim(implode("Message here?", $args)));
     
  6. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    No no no no no
    you don't have to touch any of that
    The implode is the " " SPACE in the sentence
     
  7. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    Ohhh, yes thank you!
     
  8. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    So say you did
    /commandname {The Other Players Name} {The Command} It takes the spaces in the command to be used
    so like /tell {name} blah blah blah
    without the implode it would just do /tell because it can't read the spaces
     
  9. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    But isnt there any way to talk without using a command like say or tell?
     
  10. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    yes i was just using it as an example
     
  11. Mr174

    Mr174 Baby Zombie

    Messages:
    187
    GitHub:
    mr174
    Also i dont think you need the / in the command
     
  12. Todo56

    Todo56 Silverfish

    Messages:
    17
    GitHub:
    todo56
    I'll test it out :D
     
  13. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    There's Player->chat("message")
     
    HimbeersaftLP and Fadhel like this.
  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.