User avatar
xdlewisdx
Civil Servant Zombie
Civil Servant Zombie
Posts: 12
Joined: Mon Dec 12, 2016 3:44 am
x 3

Clear Players Inventory

Tue Jan 10, 2017 6:13 am

Just wondering if there is a way of clearing a players inventory like

player.Inventory.clearInventory

or something like that?
0 x

sharkbound
Civilian Zombie
Civilian Zombie
Posts: 66
Joined: Mon Apr 06, 2015 8:36 pm
x 3

Re: Clear Players Inventory

Thu Jan 12, 2017 4:25 am

xdlewisdx wrote:Just wondering if there is a way of clearing a players inventory like

player.Inventory.clearInventory

or something like that?

Here is the main way of doing it:

Code: Select all

            UnturnedPlayer player = (UnturnedPlayer)caller;

            // Loops over each of the player's inventory pages
            for (byte page = 0; page < 8; page++)
            {
                // gets the item count for the current inventory page its looking in
                var items = player.Inventory.getItemCount(page);

                // loop over all items in current inventory page
                for (byte index = 0; index < items; index++)
                {
                    // remove the item
                    player.Inventory.removeItem(page, 0);
                }
            }
0 x

Return to “General Development Discussion”

Who is online

Users browsing this forum: No registered users and 1 guest

Advertisement