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

Ui help

Discussion in 'Development' started by ExplodingSquad, Nov 16, 2017.

  1. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
    How do if you select a item on your inventory and a ui pop-up
     
  2. Alex

    Alex Spider Jockey

    Messages:
    28
    GitHub:
    Bichwha
    What do you mean? Do you mean OnInteract?
     
  3. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
    Yes
    I will making it for my server
     
  4. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
    Yes
     
  5. Irish

    Irish Baby Zombie

    Messages:
    156
    GitHub:
    irishpacks
    Show a previous attempt, we're not going to just whoosh you up code because you ask. Also, I'd try using the search bar while you're at it.
     
    jasonwynn10 likes this.
  6. Alex

    Alex Spider Jockey

    Messages:
    28
    GitHub:
    Bichwha
    use player interact event to detect what block they’re holding, then use Server::dispatchCommand() to run a command as the player
     
    ExplodingSquad and jasonwynn10 like this.
  7. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
    Thanks help me a lot
     
  8. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
    Can u give me example of the code?
     
  9. jasonwynn10

    jasonwynn10 Moderator Poggit Reviewer

    Messages:
    1,489
    GitHub:
    jasonwynn10
     
  10. Alex

    Alex Spider Jockey

    Messages:
    28
    GitHub:
    Bichwha
    Ill be helpful


    PHP:

    public function onInteract(PlayerInteractEvent $event){
    $player $event->getPlayer();
    $item $event->getItem();

       if(
    $item->getId() == Add item id here){
            
    $command "Add command here";
            
    $this->getServer()->getCommandMap()->dispatch($event->getPlayer(), $command);
        }

    }


    Make sure to use 
    pocketmine\event\player\PlayerInteractEvent;
     
  11. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
    'dispatch' to dispatchCommand why you use again '$event->getPlayer ()' on the function dispatch if you have already defined $player....
     
    jasonwynn10 likes this.
  12. Ant

    Ant Spider

    Messages:
    9
    GitHub:
    Dead
    Premature optimization is root of all evil - @PEMapModder
     
  13. SOFe

    SOFe Administrator Staff Member PMMP Team Poggit Admin

    Messages:
    1,968
    GitHub:
    sof3
    jasonwynn10 and ItzAribie like this.
  14. Ant

    Ant Spider

    Messages:
    9
    GitHub:
    Dead
  15. ItzAribie

    ItzAribie Spider Jockey

    Messages:
    41
  16. ExplodingSquad

    ExplodingSquad Spider

    Messages:
    13
    GitHub:
    CreeperAsGaming
     
  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.