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

ConsoleCMDSender

Discussion in 'Development' started by Kkora, Nov 11, 2018.

  1. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    Hey guys, is this possible to use?
    PHP:
    $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "give ".$name." paper 1 {display:{Name:"§r§6§lMedal"},Unbreakable:1}");
     
  2. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
     $this->getServer()->dispatchCommand(new ConsoleCommandSender(), "give ".$name." paper 1 {display:{Name:§r§6§lMedal},Unbreakable:1}"); 
     
  4. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    if i do this?
    PHP:
    $item setCustomName("Test");
    $sender->getInventory->addItem->$item
    hmm...
     
  5. Palente

    Palente Slime

    Messages:
    75
    GitHub:
    palente
    Oh no
    setCustomName is available in the class Item.
    So $item must be instanceof Item
    Exemple
    PHP:
    $id 4// The id of the item
    $item Item::get($id,0,2);
    $item->setCustomName("test");
    #To dont have error check if player is an instanceof Player
    $sender->getInventory()->addItem($item);
     
    Last edited: Nov 12, 2018
  6. xXNiceAssassinlo YT

    xXNiceAssassinlo YT Zombie Pigman

    Messages:
    499
    GitHub:
    xXNiceYT
    I rather not use dispatch lol use this

    PHP:
    $item Item::get(Item::PAPER);
    $item->setCustomName("§6§lMedal");
    $player->getInventory()->addItem($item);
     
  7. Kkora

    Kkora Baby Zombie

    Messages:
    189
    GitHub:
    shisui203
    yes, that is the best answer i'm finding now! Tks.
     
  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.