1

Need Help With a Command Block Mechanic.

Tripyronix •2/15/17 3:08 am
•
299
•
2/16/2017 10:55 pm
I'm using this to assign players a number when they join(player 1, player 2, etc.) so i can select each player individually and complete operations on them using their own scores, such as giving points for damage dealt.

Problem: I currently have to make Health & Points Functions(see below) for every possible player(i have capped it at 12 players currently, hence the code for the 13th player, i know this has issues just ignore it.), i would prefer to have no cap, but i don't want to make an infinite number of command blocks for every possible player, So i'm wondering if there is a way to affect; any given 'numbered player' separately with one function?
if i run the 'Health Function' to target just anyone, players could lose health for someone else taking damage because the command would default to how far away the players are.
Please Help!!

Commands for Setup:
Impulse /scoreboard objectives add left stat.leaveGame LeftGame
Impulse /scoreboard objectives add pc dummy PlayerCount
Impulse /scoreboard objectives add fpc dummy FauxPlayerCount
Impulse /scoreboard players set fauxplayer fpc 1
Impulse /scoreboard objectives add h dummy Health
Impulse /scoreboard objectives add p dummy Points
Impulse /scoreboard objectives add dt stat.damageTaken DamageTaken
Impulse /scoreboard objectives add dd stat.damageDealt DamageDealt

Player Number Assigning Function:
Repeat Active /scoreboard players set @a[tag=!player] pc 0
Chain Conditional /scoreboard players operation @a[tag=!player] pc += fauxplayer fpc
Chain Conditional /scoreboard players tag @a[tag=!player] add player
Chain Conditional /scoreboard players add fauxplayer fpc 1
Chain Conditional /execute @a[score_pc_min=13] ~ ~ ~ scoreboard players set @a[score_pc_min=13] left 1
Chain Conditional /scoreboard players set fauxplayer fpc 1


The 13th Player Function:
Repeat Active /execute @a[score_pc_min=13,score_left_min=1] ~ ~ ~ scoreboard players set @a[score_pc_min=13,score_left_min=1] pc 0
Chain Conditional /scoreboard players tag @a[score_left_min=1] remove player
Chain Conditional /scoreboard players set @a[score_left_min=1] left 0


Command for Health Function:
Repeat Active /execute @a[score_pc=#,score_pc_min=#,score_dt_min=1] scoreboard players operation @a[score_pc=#,score_pc_min=#,score_dt_min=1] h -= @a[score_pc=#,score_pc_min=#,score_dt_min=1] dt
Chain Conditional /scoreboard players set @a[score_pc=#,score_pc_min=#,score_dt_min=1] dt 0

Command for Points Function:
Repeat Active /execute @a[score_pc=#,score_pc_min=#,score_dd_min=1] scoreboard players operation @a[score_pc=#,score_pc_min=#,score_dd_min=1] p += @a[score_pc=#,score_pc_min=#,score_dd_min=1] dd
Chain Conditional /scoreboard players set @a[score_pc=#,score_pc_min=#,score_dd_min=1] dt 0
Posted by
Tripyronix
Level 1 : New Miner
0

  Have something to say?

Join • Sign in

2

Lexxer
• 02/15/2017 7:16 am
• Level 29 : Expert Caveman
You can just target the player who took damage and the target the nearest player:

/execute @a[score_dt_min=1] ~ ~ ~ scoreboard players operation @p[c=1] h -= @p[c=1] dt

This will target all players who took damage but since the nearest player is the player who got targeted by the execute command, this should solve your problem.
1
Tripyronix
• 02/16/2017 10:55 pm
• Level 1 : New Miner
Thanks!! seems to be working saves the need to assign players a number, but not a bad system to use for other things anyway
1

Welcome