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

Adding an item to a specific place in a player inventory?

Discussion in 'Development' started by Zach1603, Aug 11, 2018.

  1. Zach1603

    Zach1603 Spider Jockey

    Messages:
    27
    GitHub:
    zedstar16
    How could you add an item to a specific place in a player's inventory, for example the top right corner?
     
  2. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    You can't, unfortunately.
     
  3. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    PHP:
    $slot 9;
    $item Item::get(101);
    $player->getInventory()->setItem($slot$item);
     
    Zach1603 and Muqsit like this.
  4. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    That doesn't guarantee top right corner.
     
    OnTheVerge likes this.
  5. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    It is top left. $slot = 17; is top right
     
  6. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    But does that apply to both Classic and Pocket UI?
     
    Zach1603 and OnTheVerge like this.
  7. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    You can get the "UIProfile" as named in the clientData... but I tested that on Classic. Pocket UI is no longer used by the players, not that much, but why not being the same?
     
  8. Muqsit

    Muqsit Chicken

    Messages:
    1,548
    GitHub:
    muqsit
    Neither the UI scale nor their OS has anything to do with it, sadly.
    It differ based on your screen resolution.
     
    corytortoise likes this.
  9. MalakasPlayzMCPE

    MalakasPlayzMCPE Zombie Pigman

    Messages:
    667
    Really? If I setItem(0, $item); would it be to a random slot?
     
  10. corytortoise

    corytortoise Skeleton

    Messages:
    825
    GitHub:
    corytortoise
    It would be the first slot, I assume, but the problem is finding the other corner slots. It could be 9 for you, but also 5 for a phone, and 6 for a tablet.
     
    Zach1603, OnTheVerge and Muqsit 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.