How do you clear someone's inventory upon spawn?

I'm trying to start a server that clears your inventory when spawning without pressure plates. Please help.

2

4 Answers

You can use the command /clear [targets] [item] [maxCount], where:

  • targets is optional. It is the name of the player (or a target selector) whose inventory you wish to clear. If no player is specified, it will default to the player running the command.

  • item is optional. It is the item to clear (See list of Minecraft items). If no item is specified, then all items in the player's inventory will be cleared.

  • maxCount is optional. It is the maximum number of items that will be cleared. If you omit this parameter or use -1, all matching items will be cleared.

For your requirements, I suggest /clear @p, on a command block looping right bellow the player.

the best way that I can think of is to make a command where every player except certain players have a repeat command the clears their inventory like this:

/clear @a[name=!NAME,name=!NAME,name=!NAME]

replace the extra name with names of players that you want their items to not be removed for example

/clear @a[name=!Steve,name=!NoobSlayer700,name=!Steve(1),name=!Dinnerbone]

this will clear all player inventories except Steve,NoobSlayer700,Steve(1) and Dinnerbone

There are many ways to do this. First I need to know:

  • Do you want to make a PVP server or a freebuild server or something else?
  • In which cases do you want to clear the player's inventory?
  • Which version and console do you use?

What you can do is set the spawnpoint into a cube on bedrock, somewhere near to y=5 or so, and then clear the inventory of every player which is in the cube, and finally, teleport these players to the real spawn.

I only know of a method for computer and mobile.
On computer press T and type: /gamerule keepinventory false. The only thing is, on a Server, you might need to use command blocks. To do this use the command: /give (YOURUSERNAME) minecraft:command_block, enter the first command into the command block, and set the command block to always active from within the command Block and you should be good to go. On mobile: pause the game, go into settings, and then game. Scroll down until you see the word: Cheats. Scroll a little further until you see: Keep Inventory and toggle the switch right until it is to the right.

You Might Also Like