-
Notifications
You must be signed in to change notification settings - Fork 75
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Inventory sending #232
Comments
Use a listener to handle transactions occurring within the menu. $menu->setListener(function(InvMenuTransaction $transaction) : InvMenuTransactionResult{
$player = $transaction->getPlayer();
if(/* $player is not allowed */){
return $transaction->discard();
}
return $transaction->continue();
}); |
It is not working |
Can you clarify what's not working exactly? |
yep it was sending same inv |
Menus can be sent to multiple players, you must store the menu instance in memory to pass it around. |
You mean in that player game it should store? |
Store it within the plugin temporarily, in an array. https://github.com/BlockHorizons/InvSee as an example allows permission-based control over player inventories in real-time. |
If you want to send the same menu with different inventories, it is not possible. You'd need to create a different menu for each inventory. Plugins usually construct a new menu at request: https://github.com/search?q=InvMenu%3A%3Acreate+language%3APHP&type=code If you want to send the same menu to multiple players, you may want to cache the menu somewhere in memory so you retain an instance to the menu. $menu = InvMenu::create(InvMenu::TYPE_CHEST);
$menu->send($player1);
$menu->send($player2);
// allow only $player1 to make changes
$menu->setListener(function(InvMenuTransaction $transaction) use($player1) : InvMenuTransactionResult{
$player = $transaction->getPlayer();
if($player === $player1){
return $transaction->continue();
}
return $transaction->discard();
}); |
How can we full whole gui with one line code and also add some item in particular slots |
Please reply |
Why not just write a function that builds a menu? |
How can we send same inventory to different player but the inside content that first user saved can only be seen by him if other open he sees his placed items
The text was updated successfully, but these errors were encountered: