I recently have been working on a spleef game where the last person alive wins. The problem is, I don't know how I would detect the last player alive. I was thinking I could do it with a scoreboard but I don't know how I would do that, and all the tutorials use /testfor which doesn't exist in 1.13. What would be the best way to do it?
P.S. there also might be players joining a lobby area in the same world as the spleef arena while a game is in progress (it's for a server)
Tag is for differentiating in-game player and guest/spectator.
deathCount scoreboard is for...well you know.
For those who join the game, give them a tag(ingame) and a deathCount score of -1.
execute store result score @p testdummy if entity @a[tag=ingame,scores={deathCount=-1}]
When the entity who store this score(@p in this case) has a score of 1, it means there's only one player alive.
Then execute as @a[tag=ingame,scores={deathCount=-1}] at @s run say HI would let this player say HI...
Or you can use scoreboard operation to add every player's deathCount score together. Only one left if the total score is -1. Then use execute as @a[scores={deathCount=-1}]... to detect...
Tag is for differentiating in-game player and guest/spectator.
deathCount scoreboard is for...well you know.
For those who join the game, give them a tag(ingame) and a deathCount score of -1.
execute store result score @p testdummy if entity @a[tag=ingame,scores={deathCount=-1}]
When the entity who store this score(@p in this case) has a score of 1, it means there's only one player alive.
Then execute as @a[tag=ingame,scores={deathCount=-1}] at @s run say HI would let this player say HI...
Or you can use scoreboard operation to add every player's deathCount score together. Only one left if the total score is -1. Then use execute as @a[scores={deathCount=-1}]... to detect...
I'm so sorry, but still can't seem to wrap my head around this, even though it seems like I'm almost getting it...
Could you perhaps provide an image, or a few more words of clarification? Or, in other words, could you say where each command should go?
I tried this on my map too, but when my brother joined the game, it didn't worked.
I use 1.13.2. Is there alternative way to do that?
Everything worked fine when I did it without my brother joined. It normally posted "[my nick] LAST PLAYER"
Edit: I used function that shows scoreboard while clicking TAB. When I have -1 and my brother 0, it doesn't works BUT when my brother leaves server I get message.
I did everything what you said in post #4. Command block shows something like "Test passed with 2 entities" and that's all. Nothing happens next if my brother will not leave server
Can you maybe make a video and show how it should looks like? Remember that it works when I'm alone at server but when they are 2+ people, it doesn't work until someone leaves.
I recently have been working on a spleef game where the last person alive wins. The problem is, I don't know how I would detect the last player alive. I was thinking I could do it with a scoreboard but I don't know how I would do that, and all the tutorials use /testfor which doesn't exist in 1.13. What would be the best way to do it?
P.S. there also might be players joining a lobby area in the same world as the spleef arena while a game is in progress (it's for a server)
Tag is for differentiating in-game player and guest/spectator.
deathCount scoreboard is for...well you know.
For those who join the game, give them a tag(ingame) and a deathCount score of -1.
execute store result score @p testdummy if entity @a[tag=ingame,scores={deathCount=-1}]
When the entity who store this score(@p in this case) has a score of 1, it means there's only one player alive.
Then execute as @a[tag=ingame,scores={deathCount=-1}] at @s run say HI would let this player say HI...
Or you can use scoreboard operation to add every player's deathCount score together. Only one left if the total score is -1. Then use execute as @a[scores={deathCount=-1}]... to detect...
I'm so sorry, but still can't seem to wrap my head around this, even though it seems like I'm almost getting it...
Could you perhaps provide an image, or a few more words of clarification? Or, in other words, could you say where each command should go?
Thanks so much for your help!
Slightly change...dummy isn't really need.
SETUP
scoreboard objectives add deathCount deathCount
summon area_effect_cloud ~ ~ ~ {Tags:["count"],Age:0,Duration:2147483647}
WHEN PLAYER ENTER YOUR MINI GAME, RUN
tag @a[...] add ingame
CHAIN CONDITIONAL ACTIVE
scoreboard players set @a[tag=ingame] deathCount -1
REPEAT UNCONDITIONAL ACTIVE
execute store result score @e[tag=count,limit=1] deathCount if entity @a[tag=ingame,scores={deathCount=-1}]
CHAIN CONDITIONAL ACTIVE
execute if entity @e[tag=count,scores={deathCount=1}] as @a[tag=ingame,scores={deathCount=-1}] at @s run say LAST PLAYER
A example of how command blocks are place.
Thanks so much!
I tried this on my map too, but when my brother joined the game, it didn't worked.
I use 1.13.2. Is there alternative way to do that?
Everything worked fine when I did it without my brother joined. It normally posted "[my nick] LAST PLAYER"
Edit: I used function that shows scoreboard while clicking TAB. When I have -1 and my brother 0, it doesn't works BUT when my brother leaves server I get message.
Sorry, I cannot tell what went wrong unless you show me what you did.
And AFAIK, the format doesn't change much b/t 1.13 and 1.13.2.
I did everything what you said in post #4. Command block shows something like "Test passed with 2 entities" and that's all. Nothing happens next if my brother will not leave server
Can you maybe make a video and show how it should looks like? Remember that it works when I'm alone at server but when they are 2+ people, it doesn't work until someone leaves.