Advertisement
Guest User

Distance d'un joueur à un joueur par le biais d'une flèche

a guest
Feb 2nd, 2016
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 3.36 KB | None | 0 0
  1. command /team [<text>] [<player>]:
  2.     trigger:
  3.         if arg 1 is "Blue":
  4.             set {Equipe::%arg-player%} to "Blue"
  5.             set arg-player tab name to "&9%arg-player%"
  6.            
  7.             #FLECHE
  8.             add 1 to {Fleche.Blue.NB}
  9.             set {Fleche.Blue.%{Fleche.Blue.NB}%} to arg-player
  10.            
  11.             send "&9%arg-player%&f est désormais dans l'équipe &9Bleue"
  12.            
  13. command /reset:
  14.     trigger:
  15.         clear {Equipe::*}
  16.         set {Fleche.Blue.NB} to 0
  17.         clear {Fleche.Blue.1}
  18.         clear {Fleche.Blue.2}
  19.         clear {Fleche.Blue.3}
  20.         clear {Fleche.Blue.4}
  21.         send "&2&lOK ! :)"
  22.        
  23. command /info:
  24.     trigger:
  25.         send "%{Fleche.Blue.NB}%"
  26.         send "%{Fleche.Blue.1}%"
  27.         send "%{Fleche.Blue.2}%"
  28.            
  29.            
  30. every 1 seconds:
  31.     make all players execute command "/timermaj"
  32.    
  33.    
  34.    
  35. command /timermaj:
  36.     trigger:
  37.         display board named "" to player
  38.         set name of sidebar of player to "   &3Jeu &bI   "
  39.         set score " " in sidebar of player to 5
  40.        
  41.         set {_equipe} to {Equipe::%player%} #On récupère l équipe du joueur
  42.  
  43.         loop {Fleche.%{_equipe}%.NB} times: #On loop autant de fois qu il y a de joueurs dans l équipe
  44.             set {_player} to {Fleche.Blue.%loop-number%} #On récupère le joueur "loopé"
  45.             {_player} is not player #Si le joueur "loopé" n est pas le joueur qui actualise son scoreboard
  46.             {_player} is online #Si la personne est bien en ligne
  47.            
  48.             set {_coordx1} to x-position of player #On récupère diverses infos
  49.             set {_coordx2} to x-position of {_player}
  50.             set {_distx} to {_coordx2}-{_coordx1}
  51.             set {_coordz1} to z-position of player
  52.             set {_coordz2} to z-position of {_player}
  53.             set {_distz} to {_coordz2}-{_coordz1}
  54.             set {_distxz} to sqrt of ({_distx}^2+{_distz}^2)
  55.             set {_cosangle} to {_distx} / {_distxz}
  56.             set {_sinangle} to {_distz} / {_distxz}
  57.            
  58.             if distance between player and {_player} is less than or equal to 50: #Ton morceau de code
  59.                 set {_fleche.color} to "&b&l"
  60.             else if distance between player and {_player} is more than or equal to 50: #J ai modifié le nombre car ne prenait pas en compte de 50 à 100
  61.                 set {_fleche.color} to "&9&l"
  62.             if distance between player and {_player} is more than or equal to 200:
  63.                 set {_fleche.color} to "&c&l"
  64.             if distance between player and {_player} is more than or equal to 350:
  65.                 set {_fleche.color} to "&4&l"
  66.                
  67.             if {_cosangle} is between -1 and -0.7: #On attribue une valeur à chaque direction (0=N, 1=E, 2=S, 3=O)
  68.                 set {_direction} to 3
  69.             else if {_cosangle} is between 0.7 and 1:
  70.                 set {_direction} to 1
  71.             else if {_sinangle} is between 0.7 and 1:
  72.                 set {_direction} to 2
  73.             else:
  74.                 set {_direction} to 0
  75.                
  76.             if horizontal facing of player is east: #On met un décalage en fonction de la direction du joueur
  77.                 remove 1 from {_direction}
  78.             else if horizontal facing of player is south:
  79.                 remove 2 from {_direction}
  80.             else if horizontal facing of player is west:
  81.                 remove 3 from {_direction}
  82.            
  83.             if {_direction} is smaller than 0:
  84.                 add 4 to {_direction}
  85.                
  86.             if {_direction} is 0: #On attribue une flèche
  87.                 set {_fleche} to "^"
  88.             else if {_direction} is 1:
  89.                 set {_fleche} to ">"
  90.             else if {_direction} is 2:
  91.                 set {_fleche} to "v"
  92.             else if {_direction} is 3:
  93.                 set {_fleche} to "<"
  94.                
  95.             set score "%{_player}% %{_fleche.color}%%{_fleche}%" in sidebar of player to loop-number #On affiche la flèche avec le joueur approprié
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement