using function for name in chat

This commit is contained in:
Mylloon 2021-06-29 21:07:16 +02:00
parent 96db6484bd
commit f6deddbb34
3 changed files with 37 additions and 26 deletions

View file

@ -22,3 +22,11 @@ function ScriptList(addRemove: text, list: text):
add {_list} to {scripts::*} add {_list} to {scripts::*}
if {_addRemove} is "remove": if {_addRemove} is "remove":
remove {_list} from {scripts::*} remove {_list} from {scripts::*}
function userOrNick(player: player) :: text:
set {_uuid} to uuid of {_player}
if {nick.%{_uuid}%} is set:
set {_res} to {nick.%{_uuid}%}
else:
set {_res} to name of {_player}
return {_res}

19
chat.sk
View file

@ -5,24 +5,29 @@ on unload:
on chat: # chat on chat: # chat
cancel event cancel event
if {nick.%uuid of player%} is set: set {_player} to userOrNick(player)
set {_player} to {nick.%uuid of player%}
else:
set {_player} to player's name
broadcast "<%{_player}%&r> %colored message%" in world of player broadcast "<%{_player}%&r> %colored message%" in world of player
command nickname [<player>] <text>: # changement de pseudo command nickname [<player>] [<text>]: # changement de pseudo
executable by: players executable by: players
aliases: nick aliases: nick
description: Change ton nom ou celui d'un autre joueur. (max 15 charactères) description: Change ton nom ou celui d'un autre joueur. (max 15 charactères)
trigger: trigger:
if player is op:
set {_playerUUID} to uuid of player set {_playerUUID} to uuid of player
set {_player} to player set {_player} to player
set {_playerNAME} to player set {_playerNAME} to player
if arg-1 is set: if arg-1 is set:
set {_playerUUID} to uuid of arg-1 set {_playerUUID} to uuid of arg-1
set {_player} to arg-1 set {_player} to arg-1
if arg-2 is not set:
if {nick.%{_playerUUID}%} is set:
set {_deb} to "Le surnom de %{_playerNAME}%"
if player is {_player}:
set {_deb} to "Votre surnom"
send "%{_deb}% est : %{nick.%{_playerUUID}%}%"
else:
send "Tu n'as pas de surnom. Nom d'affichage : %{_playerNAME}%"
stop
if player is {_player}: if player is {_player}:
set {_playerNAME} to "vous" set {_playerNAME} to "vous"
else: else:
@ -36,8 +41,6 @@ command nickname [<player>] <text>: # changement de pseudo
else: else:
set {nick.%{_playerUUID}%} to colored arg-2 set {nick.%{_playerUUID}%} to colored arg-2
send "&6Ton surnom est désormais &r%{nick.%{_playerUUID}%}%&6. (changé par %{_playerNAME}%&6)" to {_player} send "&6Ton surnom est désormais &r%{nick.%{_playerUUID}%}%&6. (changé par %{_playerNAME}%&6)" to {_player}
else:
send option("errorMessage")
command msg <player> <text>: # DM command msg <player> <text>: # DM
executable by: players executable by: players

View file

@ -78,7 +78,7 @@ command rename <text>: # renomme l'item dans la main du joueur
set {_name} to colored arg-1 set {_name} to colored arg-1
replace all "&" with "§" in {_name} replace all "&" with "§" in {_name}
send "&eL'item &r%player's tool%&e est renommé en ""&r%{_name}%&e""." send "&eL'item &r%player's tool%&e est renommé en ""&r%{_name}%&e""."
set the name of the player's tool to "§r%{_name}%" set name of the player's tool to "§r%{_name}%"
else: else:
send option("errorMessage") send option("errorMessage")