Je n'avais pas pu tester mon skript avec 2 joueurs auparavant et je viens de me rendre compte que le scoreboard ne se mettait à jour que pour le dernier joueur arrivé sur le serveur.
J'edit donc mon premier message avec un code fonctionnel.
Nb : Je reset un scoreboard entier toutes les secondes à chaque joueur, on peut reset seulement la ligne voulue mais je ne crois pas que le gain de performance soit remarquable
Salut
on damage:
if projectile is an arrow:
if attacker and victim is a player:
set {victimName::%attacker%} to victim
on death:
if attacker and victim is a player:
delete {victimName::%attacker%}
delete {victimName::%player%}
on quit:
loop all players in world "world":
if player is {victimName::%loop-player%}:
delete {victimName::%loop-player%}
delete {victimName::%player%}
every second:
loop all players in world "world":
wipe loop-player sidebar
set name of sidebar of loop-player to "nomChoisi"
set score "-------------------" in sidebar of loop-player to 3
set score "&5 " in sidebar of loop-player to 2
set score "&5 " in sidebar of loop-player to 0
if {victimName::%loop-player%} is set:
set {_location} to location of {victimName::%loop-player%}
set {_direction} to direction(location of loop-player and {_location})
set {_distance} to round(flatDistance(loop-player and {_location}))
set score "%{_direction}% (%{_distance}% block(s))" in sidebar of loop-player to 1
else:
set score "[Pas de victime]" in sidebar of loop-player to 1
function direction(from: location, to: location) :: text:
set pitch of {_from} to 0.001
set {_behind} to true if (flatDistance({_from} and {_to})) - flatDistance(location 1 meter behind {_from} and {_to}) > 1/3
set {_infrontof} to true if (flatDistance({_from} and {_to})) - flatDistance(location 1 meter in front of {_from} and {_to}) > 1/3
set {_right} to true if (flatDistance({_from} and {_to})) - flatDistance(location 1 meter right {_from} and {_to}) > 1/3
set {_left} to true if (flatDistance({_from} and {_to})) - flatDistance(location 1 meter left {_from} and {_to}) > 1/3
return "⬊" if {_behind} and {_right} are true
return "⬋" if {_behind} and {_left} are true
return "⬈" if {_infrontof} and {_right} are true
return "⬉" if {_infrontof} and {_left} are true
if {_right} and {_left} are not set:
return "↑" if {_infrontof} is true
return "↓" if {_behind} is true
if {_infrontof} and {_behind} are not set:
return "←" if {_left} is true
return "➡" if {_right} is true
return "✔"
function flatDistance(from: location, to: location) :: number:
set y coordinate of {_from} to y coordinate of {_to}
return distance between {_from} and {_to}
Il reprend en majorité la fonction dont j'ai parlé au début du post et le code que j'ai fait pour adapter la fonction en scoreboard. J'ai également rajouté 2, 3 lignes pour qu'il suive le joueur touché par une flèche à la place de coordonnées précises. Tant que la victime n'est pas morte/déco ou que l'attaquant ne tire pas sur un autre joueur, la distance le séparant de sa victime reste affichée, je te laisse modifier si tu souhaites qu'il y ai un timer précis, que la flèche ai un nom précise, que le joueur attaqué ne puis pas déco etc etc.