Salut,
Je n'ai pas vraiment eu le temps aujourd'hui, j'ai refait le système des équipes, j'ai cherché un vieux code de rééquilibrage d'équipes dans mes anciens scripts. Il n'est pas très optimisé, mais il est fonctionnel, quand j'aurais le temps je t'en referais un.
Equipes :
function SetPlayerColor(p: text, color: text):
set {_p} to "%{_p}%" parsed as player
wait 0.5 tick
{_color} is "red":
if {color.%{_p}%} is "red":
send "&cErreur : Vous êtes déjà dans l'équipe rouge !" to {_p}
else:
if {team.red} >= 20:
send "&cErreur : L'équipe rouge est au complet !" to {_p}
else:
if {color.%{_p}%} is "blue":
remove 1 from {team.blue}
wait 0.1 tick
set {color.%{_p}%} to "red"
add 1 to {team.red}
set {_p} tab name to "&c%{_p}%"
set {team.%{_p}%} to true
set {mj.%{_p}%} to "Dedans"
wait 0.1 tick
send "&aVous avez rejoins l'équipe &crouge &a!" to {_p}
{_color} is "blue":
if {color.%{_p}%} is "blue":
send "&cErreur : Vous êtes déjà dans l'équipe bleue !" to {_p}
else:
if {team.blue} >= 20:
send "&cErreur : L'équipe bleue est au complet !" to {_p}
else:
if {color.%{_p}%} is "red":
remove 1 from {team.red}
wait 0.1 tick
set {color.%{_p}%} to "blue"
add 1 to {team.blue}
set {_p} tab name to "&9%{_p}%"
set {team.%{_p}%} to true
set {mj.%{_p}%} to "Dedans"
wait 0.1 tick
send "&aVous avez rejoins l'équipe &9bleue &a!" to {_p}
on rightclick with red wool:
if {ingame} is false:
cancel event
SetPlayerColor("%player%", "red")
on rightclick with blue wool:
if {ingame} is false:
cancel event
SetPlayerColor("%player%", "blue")
Pour savoir si l'équipe d'un rouge est rouge ou bleue, tu fais "if {color.%player%} is "red"" pour rouge, et tu remplaces "red" par "blue" pour les bleus.
Vieux débris de rééquilibrage des équipes :
function DividePlayers(players: text="get"):
if {team.red} > {team.blue}:
loop all players:
if {color.%loop-player%} is not set:
add loop-player to {_players::*}
wait 0.5 tick
set {_diff} to difference between {team.red} and {team.blue}
set {_r} to 1
loop {_diff} times:
set {_p.%{_r}%} to a random element out of {_players::*}
add 1 to {_r}
wait 1 tick
set {_r} to 1
wait 0.1 tick
loop {_diff} times:
SetPlayerColor("%{_p.%{_r}%}%", "blue")
add 1 to {_r}
wait 2 ticks
delete {_players::*}
loop all players:
if {color.%loop-player%} is not set:
add loop-player to {_players::*}
wait 2 ticks
set {_size} to size of {_players::*}
wait 0.1 tick
set {_size} to {_size} / 2
wait 0.1 tick
set {_r} to 1
loop {_size} times:
set {_p.s.%{_r}%} to a random element out of {_players::*}
add 1 to {_r}
wait 1 tick
set {_r} to 1
set {_random} to a random integer between 1 and 2
wait 0.5 tick
{_random} is 1:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "red")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "blue")
else:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "blue")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "red")
else if {team.red} < {team.blue}:
loop all players:
if {color.%loop-player%} is not set:
add loop-player to {_players::*}
wait 0.5 tick
set {_diff} to difference between {team.red} and {team.blue}
set {_r} to 1
loop {_diff} times:
set {_p.%{_r}%} to a random element out of {_players::*}
add 1 to {_r}
wait 1 tick
set {_r} to 1
wait 0.1 tick
loop {_diff} times:
SetPlayerColor("%{_p.%{_r}%}%", "red")
add 1 to {_r}
wait 2 ticks
delete {_players::*}
loop all players:
if {color.%loop-player%} is not set:
add loop-player to {_players::*}
wait 2 ticks
set {_size} to size of {_players::*}
wait 0.1 tick
set {_size} to {_size} / 2
wait 0.1 tick
set {_r} to 1
loop {_size} times:
set {_p.s.%{_r}%} to a random element out of {_players::*}
add 1 to {_r}
wait 1 tick
set {_r} to 1
set {_random} to a random integer between 1 and 2
wait 0.5 tick
{_random} is 1:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "blue")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "red")
else:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "red")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "blue")
else if {team.red} = {team.blue}:
loop all players:
if {color.%loop-player%} is not set:
add loop-player to {_players::*}
wait 2 ticks
set {_size} to size of {_players::*}
wait 0.1 tick
set {_size} to {_size} / 2
wait 0.1 tick
set {_r} to 1
loop {_size} times:
set {_p.s.%{_r}%} to a random element out of {_players::*}
add 1 to {_r}
wait 1 tick
set {_r} to 1
set {_random} to a random integer between 1 and 2
wait 0.5 tick
{_random} is 1:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "blue")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "red")
else:
loop {_size} times:
SetPlayerColor("%{_p.s.%{_r}%}%", "red")
add 1 to {_r}
wait 2 ticks
loop all players:
if {color.%loop-player%} is not set:
SetPlayerColor("%loop-player%", "blue")
Pour rééquilibrer les équipes, tu utilises tout simplement l'effet "DividePlayers()". Il faudra aussi à delete les variables {color.%player%} à la fin de la partie.