2

I'm trying to make two teams that are the "good guys" and the "bad guys". I'd like it to be like a reputation system where you get good karma for killing bad guys and bad karma for killing anyone but the bad guys.

So far I'm using the following commands:

/scoreboard teams add Team1 Fugitives

/scoreboard teams option Team1 color red

and

/scoreboard teams add Team2 Rescuers

/scoreboard teams option Team2 color blue

I'd like use a command or a command within a command block to do something like the following.

if(playerkillsplayer = true){
variable + 1
}

if(playerkillsFugitive = true){
variable - 1
}

if(variable > 0 ){
team ==  Team1
}

if(variable < 1){
team == Team2
}

How can I do this?

1 Answer 1

2

Before you begin,

Use a scoreboard to detect kills:

/scoreboard objectives add kills playerKillCount

One for karma:

/scoreboard objectives add karma dummy Karma

One for deaths:

/scoreboard objectives add death dummy deathCount

And one for a time since last kill:

/scoreboard objectives add timeSinceKill dummy

Finally, have a clock with the following command:

/scoreboard players add @a timeSinceKill 1

Now that the scoreboards are set up, let's begin.

For the first section of code:

if(playerkillsplayer = true){
variable + 1
}

Have the following three commands in a 20 tick clock, making sure that the third command is activated last:

/scoreboard players add @a[score_kills_min=1] karma 1
/scoreboard players set @a[score_kills_min=1] timeSinceKill 0
/scoreboard players set @a kills 0

For the second section:

if(playerkillsFugitive = true){
variable - 1
}

Note: If you want people to be able to reverse their lost karma for killing a good person, change variable - 1 to variable - 2 I'm going to assume you want for people to be able to reverse, otherwise change the 2 to 1 in the commands.

Now have the following commands on a clock powered in the following order:

A limitation is that if another one killed another person in the last 1/10 of a second, it will be activated twice. However, this is very unlikely.

/execute @a[score_death_min=1] ~ ~ ~ scoreboard players remove @p[score_timeSinceKill=2] karma 2
/scoreboard players set @p death 0

Finally, the last two sections:

if(variable > 0 ){
team ==  Team1
}

if(variable < 1){
team == Team2
}

For the first section, on a clock have

/scoreboard teams join Team1 @a[score_karma_min=1]

Second, have a command on a clock:

/scoreboard teams join Team2 @a[score_karma=0]
2
  • You should not be using /execute in this manner. Firstly, you are mixing @a, which can target dead players, with @p, which cannot target dead players. While a dead player will run the /scoreboard command, they will not target themselves. Secondly, /execute should only be used when origin or sender needs to be changed, which is not the case. /scoreboard has a target selector for you to use, example: /scoreboard players add @a[score_kills_min=1] karma 1. Every case of /execute you have can be removed, as it otherwise only serves to increase server workload.
    – Skylinerw
    Commented Feb 24, 2016 at 23:11
  • 1
    You were right, except for /execute @a[score_death_min=1] ~ ~ ~ scoreboard players remove @p[score_timeSinceKill=2] karma 2. Here, I'm not trying to target the person with the death, but the other way around would require /testfor. I will fix the others, though.
    – user139899
    Commented Feb 24, 2016 at 23:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.