SmartlyDressedGames / Unturned-3.x-Community

Community portion of the Unturned-3.x repo. If you have access to the source code you can find it here:
https://github.com/SmartlyDressedGames/Unturned-3.x/
83 stars 17 forks source link

The signal to close the inventory. #4424

Closed Syetag closed 1 month ago

Syetag commented 1 month ago
  1. In my script, I create a new storage and send it to the player:
        UnturnedPlayer player = (UnturnedPlayer)caller;
        var inventory = new Items(7);
        inventory.resize(10, 15);
        player.Player.inventory.updateItems(7, inventory);
        player.Player.inventory.sendStorage();
  1. Then in the main script, I connect to the gesture change signal:

UnturnedPlayerEvents.OnPlayerUpdateGesture += OnPlayerUpdateGesture;

  1. And then when the signal is triggered with the condition gesture == PlayerGesture.InventoryClose. I'm calling the logic for my Storage when I close it:
        private void OnPlayerUpdateGesture(UnturnedPlayer player, PlayerGesture gesture)
        {
            if (gesture == PlayerGesture.InventoryClose)
            {
                sellCommand.SellItems(player);
            }
        }

    The problem is that the inventory closing signal is triggered only if there is nothing in your hands. How else can I check if the player has closed the inventory and (if possible) the created storage.

GazziFX commented 1 month ago

check if he moves

sunnamed434 commented 1 month ago

Here I described solution : https://github.com/SmartlyDressedGames/Unturned-3.x-Community/discussions/4263#discussioncomment-8659990

SDGNelson commented 1 month ago

Thanks sunnamed434 and GazziFX for suggesting workarounds!