You should use a dummy variable and target selector arguments.
Run once
Have a dummy score, call it healthDif
.
/scoreboard objectives add healthDif dummy
Run every tick, in order
Set each players healthDif
score to their own health score:
/execute @a ~ ~ ~ scoreboard players operation @a[c=1] healthDif = @a[c=1] health
Subtract the other player's healthDif
score from your own:
/execute @a ~ ~ ~ scoreboard players operation @a[c=1] healthDif -= @a[rm=0] health
Now players with a positive healthDif
score will have more health than the other player. Target with @a[score_healthDif=1]
Note this will only work for two players. In order for it to work with more, you have to take a few extra steps.
Run once
First you'll need a dummy variable to store miscellaneous variables. Call it vars
. Note: If you already have a variable for this (you likely do), you can skip this step.
/scoreboard objectives add vars dummy
Run every tick, in order
Put these between the two commands from before.
First, set the #nplayers
to 0:
/scoreboard players set #nplayers vars -1
Now, have each player increment #nplayers
:
/execute @a ~ ~ ~ scoreboard players add #nplayers vars 1
Finally, multiply each players healthDif
score by this number
/scoreboard players operation @a healthDif *= #nplayers vars
This way, you can have any amount of players, and the system automatically adapts!
If you don't care about what entity they hit, you could do this:
Add a scoreboard called "Attack" using stat.damageDealt using:
/scoreboard objectives add Attack stat.damageDealt
And then creating this chain of command blocks:
Repeating: /scoreboard players add @a[score_Attack_min=1] Points 10
Chain: /scoreboard players set @a[score_Attack_min=1] Attack 0
This will basically add 10 to the "Points" variable every time the player deals a single point of damage. Keep in mind that stat.damageDealt doesn't count up by ones, but by the amount of damage actually dealt (ie. 16), so if they somehow do damage faster than 20x per second, it won't count every single hit.
Additionally, if you only want it to go up when the player attacks a zombie, you could use the score of:
stat.killEntity.Zombie
Best Answer
If you would make the custom mob you want to get points from killing, drop a specific item then you could execute off the item. Here is a example... Summon in the custom mob use a command like this:
You also need a objective called point. /scoreboard objectives add point dummy Then you need a clock running the following commands in this order:
scoreboard players set @e[type=Item] {Item:{id:redstone,tag:{display:{Name:"Point",Lore:[Point]}}}} point 1
execute @e[type=Item,score_point_min=1,score_point=1] ~ ~ ~ scoreboard players add @p point 1
kill @e[type=Item,score_point_min=1,score_point=1]
I would use this to summon in the custom mob you want. Hope this helps! If anything was wrong or anything was spelled wrong please tell me!