TransWikia.com

In a given location, how can I give a player some item?

Arqade Asked on June 7, 2021

So I want to make some minigame where players can get a certain item when they get into a specific location, where then they can craft with it and then PVP.

So I thought of using the /execute command to then /give them with that specific coordinate.

/execute @a x y z give @p stick

Putting this in an Always Active Repeating Command Block, it still gives me the item even if I’m not in that location.

How can I give items to a player in they’re in the given coordinates?

3 Answers

You can use the command:
/execute @e[x=#,y=#,z=#,dx=#,dy=#,dz=#] ~ ~ ~ give @s stick

Substitute the # hashtags for coordinates, and everything prefixed with d for distances.

Correct answer by Ray Wu on June 7, 2021

You can accomplish this using two command blocks, one repeating and one chain command block. One way is to put the command blocks under that specific area or another way is to not put it under that specific area but make it act upon the that area.

First, you need to lay out both command blocks assigned to one direction. Then make both blocks “Always Active”. Make the chain command block set to “Conditional”.

Repeating Command Block

Type in /testfor @a[x=?,y=?,z=?,r=?] (if your command blocks are under the specific area, you don’t need to type in the coordinates except the ‘r’ value)

Chain Command Block Or Comparator

For this stage, you can either place a redstone comparator out of the repeating command block activating other blocks or place the chain command block. In the chain command block, just type in /give @p stick

Answered by DEAN on June 7, 2021

Oh wait, I just realised that a much more easier way to do this is just place a repeating command block that is ’Always Active’ and just type in /give @a[x=?,y=?,z=?,r=?] stick

Answered by DEAN on June 7, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP