Solved onCommand and add item to player

Discussion in 'Plugin Help' started by tokoyami ds, Jul 28, 2020.

  1. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    how to onCommand and add item to player ??
    :)
     
  2. MinekCz

    MinekCz Spider Jockey

    Messages:
    28
    Code:
      public function onCommand(CommandSender $sender, Command $cmd, string $label, array $args) :bool {
        switch ($cmd->getName()) {
          case "test":
            $item = Item::get(1, 0, 64); // id, meta, count
    
            $sender->getInventory()->addItem($item); //add item to player
            
            $sender->sendMessage("You got 64 stones!"); // message
            break;
        }
        return true;
      }
    I hope it helped you
     
  3. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    407
    GitHub:
    godweedzao
    Hello, use :
    PHP:
    //onCommand Function
    case "GodWeedZao":
    $player->getInventory()->addItem(2010);
    //now adding 10 Stone Block in your inventory
    break;
    return 
    true;
    SOLVED?
     
  4. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    407
    GitHub:
    godweedzao
    you can add what ever you want to player inv bye change (2, 0, 10);
    2 is ID
    0 is META
    10 is NUMBER
     
  5. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    I know :p:facepalm:
     
  6. tokoyami ds

    tokoyami ds Spider Jockey

    Messages:
    25
    Thanks ❤
    Thanks ♡
     
  7. GodWeedZao

    GodWeedZao Zombie Pigman

    Messages:
    407
    GitHub:
    godweedzao
    Lol, np for i helped YOU :)
     

Share This Page

  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.