Why is =! not working in testfor command?
I am building a proximity alarm on a server that should go off when someone other than me approaches my house. However, the output of my command block keeps turning up as something along the lines of "The entity value is not a valid one"
My command is:
/testfor @p[name=!Myname]
The name is case sensitive, so make sure you put it right.
Also you need to enter a radius (r=radiusInBlocks
) or it will check the whole world.
Other than that it will output an error, when the detection doesn't return a result (e.g. it's just you hanging around there). Don't worry about that.
/testfor @p[name=!dly,r=3]
with just me in that radius will return an error, because there is no player around, who's not me./testfor @p[name=dly,r=3]
will return a positive.
You could as well add full coordinates, if you have the command block somewhere else.
Just add x=xValue,y=yValue,z=zValue
to your command.
This is an easy solution to your command.
If you use this command:
/execute @p[name=!YourName,r=10] ~ ~ ~ tell <YourName> Warning: @p is at your house!
and put it inside a command block on a slow Redstone clock, you will get warned each time somebody is around/in your house. I tested this on my server, and it works fine, especially when I replaced the single command block with more Command blocks with these commands:
/execute @p[name=!YourName,r=5] ~ ~ ~ tell @a[name=YourName] Warning: @p is 5 or less blocks from your house!
/execute @p[name=!YourName,r=10] ~ ~ ~ tell @a[name=YourName] Warning: @p is 10 or less blocks from your house!
/execute @p[name=!YourName,r=20] ~ ~ ~ tell @a[name=YourName] Warning: @p is 20 or less blocks from your house!