I have made/gathered an elaborate ruse of command blocks to essentially not accomplish my goal correctly. I have an objective "InCar" that tests each player to see if they are in fact in a minecart.
/scoreboard players set @a InCar 1 {RootVehicle:{Entity:{id:"MinecartRideable"}}}
And then further down the line of chain-conditional command blocks, another check which I now think it also has to be another scoreboard record. Which I haven't tested yet because of my question.
I will just ask how to only execute on the one player who is both in a minecart and with a stone block in hand in correct slot of their inventory? Or how to execute on that specific player on just one of the scoreboard items? I could go from there maybe.
Currently when 2 people or more are riding carts, they are all ejected and all carts are destroyed (like they should, minus everyone else not holding the stone). I know it is because my code to execute is not "aimed" at the player I want.
CC:
/execute @p ~ ~ ~ /tp @p ~ ~ ~2
/execute @p ~ ~ ~ /kill @e[type=MinecartRideable,r=4]
EDIT Created the InHand scoreboard
/scoreboard players set @a InHand 1 {SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}
Then had to create a 3rd scoreboard that basically only scores a point if the player has both other scoreboard items and then activates.
/execute @a[score_InCar_min=1,score_InHand=1,score_InHand_min=1] ~ ~ ~ /scoreboard players set @a eject 1
Then cleared all the scores with each command having a "negative" to their "positive" action
/execute @a[score_InCar_min=0,score_InHand=0,score_InHand_min=0] ~ ~ ~ /scoreboard players set @a eject 0
/scoreboard players set @a InHand 0
Then the final command that is working so far.
/execute @a[score_eject_min=1,score_eject=1] ~ ~ ~ /kill @e[r=2,type=MinecartRideable]
I was just tired of googling every step of the way. But I guess I am learning. I will report back any issues, or updates. Hope this finds someone well. I don't know if you can just run this and it will work, or if you do actually have to setup the scoreboard items like I did prior to creating the commands..
This is running on a SMP server with Forge and a few mods. Running 1.10.2
2ND EDIT
It worked different this time. It won't delete all the carts not occupied. But it will still delete ALL occupied carts.. -_-
3rd Edit
I am now using Venya's code to simplify the scoreboard, so my 2 command blocks for score are now.
/scoreboard players set @a eject 1 {RootVehicle:{Entity:{id:"MinecartRideable"}},SelectedItemSlot:1,Inventory:[{Slot:1b,id:"minecraft:stone"}]}
And then this inverted to that command block.
/scoreboard players set @a eject 0
And added r=2 to the first part of execute command, it went exactly how Venya said.. It was only in a 2 block radius of the command block with the command.
So the execute command isn't correct.
Just tried this execute, works good so far. Waiting for a friend or two to test out the MP implications. I think I am getting somewhere.
/execute @a ~ ~ ~ execute @a[score_eject_min=1,score_eject=1,r=2] ~ ~ ~ /kill @e[r=2,type=MinecartRideable]