Arqade Asked by Wiam on July 27, 2020
I am trying to detect when a player has quit the server, I have the scoreboard to detect when a player quits:
/scoreboard objectives add quit minecraft.custom:minecraft.leave_game
However, the rest of my command blocks only activate when the player re-joins the world. I am trying to set the player deaths to 3 when they quit:
scoreboard players set @a[scores={quit=1}] deaths 3
scoreboard players set @a[scores={quit=1}] quit 0
Is there any way to fix this?
I used something similar to add a welcome back message to a server I play on, and unfortunately, once the player leaves the game, their score cannot be incremented until they rejoin.
I tried finding a solution to this by using an ID system and checking for who is not online but marked as online in a dummy objective (using 1 and 0 as online and offline flags) and setting their here
score to 0, but because you can't test for the scores of players who are not online without explicitly naming them, the system does not work.
Hopefully someone else can come up with a different solution to your problem, however.
Answered by Nik3141 on July 27, 2020
You should try to not use the scoreboard, and instead try joining the server and when a player quits the game, a yellow message will appear in the top left corner of the screen, saying [gamertag] has left the game.
Answered by flowinglinc101 on July 27, 2020
Yes, there is a way to do this.
You can use scoreboard operations to do it. You need to have a dummy entity with the global timer. Every once in a while you'd pick a random player to test. Start by copying the player's score into a temporary score using the = operation: scoreboard players operation temp @s = timer @s. Then subtract the global timer score from the temporary score using the -= operation. If the resulting score is 0, then the timers are in sync. To sync the timer, simply copy the global timer score into the player's timer score (again using the = operation).
I think the following should work:
/scoreboard objectives add Local_Timer dummy
/scoreboard objectives add Global_Timer dummy
/scoreboard objectives add Temp_Timer dummy
execute store result score Global Global_Timer run time query gametime
scoreboard players add @a Local_Timer 1
execute as @a run scoreboard players operation @s Temp_Timer = @s Local_Timer
execute as @a run scoreboard players operation @s Temp_Timer -= Global Global_Timer
execute as @a[scores={Temp_Timer=..-1}] run say hi
execute as @a[scores={Temp_Timer=..-1}] run scoreboard players operation @s Local_Timer = Global Global_Timer```
Answered by nisse26a on July 27, 2020
Get help from others!
Recent Answers
Recent Questions
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP