Giter Club home page Giter Club logo

Comments (11)

Muqsit avatar Muqsit commented on July 30, 2024

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();
});

from invmenu.

ItsSachan avatar ItsSachan commented on July 30, 2024

It is not working
https://github.com/inxomnyaa/Backpack/tree/master like this when we interact with different it opens different inventory but the whole code is same

from invmenu.

Muqsit avatar Muqsit commented on July 30, 2024

Can you clarify what's not working exactly?

from invmenu.

ItsSachan avatar ItsSachan commented on July 30, 2024

yep it was sending same inv

from invmenu.

Muqsit avatar Muqsit commented on July 30, 2024

Menus can be sent to multiple players, you must store the menu instance in memory to pass it around.

from invmenu.

ItsSachan avatar ItsSachan commented on July 30, 2024

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?

from invmenu.

Muqsit avatar Muqsit commented on July 30, 2024

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.

from invmenu.

Muqsit avatar Muqsit commented on July 30, 2024

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. InvMenu::send() lets you send the same menu to different players.

$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();
});

from invmenu.

ItsSachan avatar ItsSachan commented on July 30, 2024

How can we full whole gui with one line code and also add some item in particular slots

from invmenu.

ItsSachan avatar ItsSachan commented on July 30, 2024

Please reply

from invmenu.

Muqsit avatar Muqsit commented on July 30, 2024

How can we full whole gui with one line code and also add some item in particular slots

Why not just write a function that builds a menu?

from invmenu.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.