essaye ca :
function jsonColor(msg: text) :: text:
if {_msg} is set:
replace all "&" in {_msg} with {@jsonchar}
set {_msg::*} to {_msg} split at ""
set {_msg} to ""
set {_cache} to ""
set {_ind} to 0
loop {_msg::*}:
add 1 to {_ind}
set {_cache} to {_msg::%{_ind}%}
if {_cache} is {@jsonchar}:
set {_nxt} to {_ind} + 1
if {_msg::%{_nxt}%} is not {@clrchars}:
set {_cache} to "&"
set {_msg} to "%{_msg}%%{_cache}%"
return {_msg}
else:
return "Error: No message set [jsonColor function]"
#
# FUNCTION: Replace all json-breaking characters
# -> Usage:
# Used by json functions to avoid errors.
# Allows usage of quotes in your json.
#
function jsonSanitize(msg: text) :: text:
if {_msg} is set:
replace all "'" in {_msg} with "\\'"
replace all """" in {_msg} with "\\"""
if {@skQueryEnabled} is true:
replace all "%%nl%%" in {_msg} with "%nl%"
return {_msg}
else:
return "Error: No message set [jsonColor function]"
#
# FUNCTION: Reformat a json.sk notation string into /tellraw json
# -> Usage:
# See the top of this skript, listed under general usage.
#
function jsonFormat(msg: text) :: text:
set {_msg} to jsonColor({_msg})
set {_lines::*} to {_msg} split at "||"
# - -- --- ---- -----> }==========={ <----- ---- --- -- -
# Json builder:
# - -- --- ---- -----> }==========={ <----- ---- --- -- -
set {_clusters} to 0
loop {_lines::*}:
set {_txt} to "%loop-value%"
#
# Assigning where each part of the json should go.
# (Dividing into clusters for easier json management)
#
# event||[text]
#
# Events: (1 per cluster)
# (Unless you want to modify this skript, please ignore the following comments because it may become confusing.)
# (The grouping is completely automated)
# non - no event, just text
# clk - click event
# hvr - hover event
#
set {_jID} to the first 4 characters of {_txt}
if {_jID} is "ttp:" or "cmd:" or "sgt:" or "url:":
if {_jID} is "ttp:":
add "hvr||%{_txt}%" to {_cluster-%{_clusters}%::*}
else:
add "clk||%{_txt}%" to {_cluster-%{_clusters}%::*}
else:
add 1 to {_clusters}
add "non||%{_txt}%" to {_cluster-%{_clusters}%::*}
if {_clusters} < 1:
return """JSON ERROR: No text value"""
stop
else:
set {_json} to "[{text:""""},||]"
set {_ind} to 1
set {_done} to ""
while {_ind} is less than or equal to {_clusters}:
if {_cluster-%{_ind}%::*} is set:
loop {_cluster-%{_ind}%::*}:
set {_txt} to "%loop-value%"
set {_txt::*} to {_txt} split at "||"
set {_jType} to {_txt::1}
set {_txt} to {_txt::2}
set {_txt} to jsonSanitize({_txt})
if {_jType} is not "non":
if {_current} is not set:
return """JSON ERROR: Attempt to create event before text value @ cluster:%{_ind}%"""
stop
else:
set {_jID} to the first 4 characters of {_txt}
set {_txt} to subtext of {_txt} from characters 5 to the length of {_txt}
if {_jType} is "hvr":
replace "||" in {_current} with ",hoverEvent:{action:show_text,value:""||~||""}||"
set {_curr::*} to {_current} split at "||~||"
set {_current} to "%{_curr::1}%%{_txt}%%{_curr::2}%"
else:
if {_jID} is "cmd:":
replace "||" in {_current} with ",clickEvent:{action:run_command,value:""||~||""}||"
if {_jID} is "sgt:":
replace "||" in {_current} with ",clickEvent:{action:suggest_command,value:""||~||""}||"
if {_jID} is "url:":
replace "||" in {_current} with ",clickEvent:{action:open_url,value:""||~||""}||"
set {_curr::*} to {_current} split at "||~||"
set {_current} to "%{_curr::1}%%{_txt}%%{_curr::2}%"
else:
set {_current} to "{text:""%{_txt}%""||}"
# Done looping a cluster:
replace all "||" in {_current} with ""
if {_ind} is {_clusters}:
set {_done} to "%{_done}%%{_current}%"
else:
set {_done} to "%{_done}%%{_current}%,"
delete {_current}
else:
set {_ind} to {_clusters} + 1
add 1 to {_ind}
set {_json::*} to {_json} split at "||"
set {_json} to "%{_json::1}%%{_done}%%{_json::2}%"
return {_json}
#
# FUNCTION: Send a json message with json.sk notation
# -> Usage:
# See the top of this skript, listed under general usage.
#
function json(to: text, msg: text):
set {_msg} to jsonFormat({_msg})
execute console command "/tellraw %{_to}% %{_msg}%"
options:
cooldown : 5 minutes
command /sgi [<text>] [<text>]:
aliases: /help
trigger:
if arg 1 is not set:
send " "
json("%player%"," &b» &6Commande modérateur &b«||ttp:&bVoir les commandes de modération||cmd:/sgi staff")
send " "
json("%player%"," &b» &6Commande joueur &b«||ttp:&bVoir les commandes des joueurs de base||cmd:/sgi joueur")
send " "
json("%player%"," &b» &6Réseau Sociaux &b«||ttp:&bVoir sur quel réseau sociaux nous suivre !||cmd:/sgi reseau")
send " "
if arg 1 is "joueur":
send " &c[&eCommande Joueur&c]"
send " "
json("%player%","&6» &bSPAWN &7(Vous retournez au spawn en cliquant dessus)||ttp:&bTéleporter vous au spawn avec &2/spawn||cmd:/spawn")
send " "
json("%player%","&6» &eKITS &7(Voir les kits que vous disposez)||ttp:&bEn cliquant ici vous aurez la liste de vos kits disponnible||cmd:/kit")
send " "
json("%player%","&6» &bTPA &7/ &2TPYES &7/ &2TPACCEPT &7/ &cTPDENY||ttp:&bTPA &7» &eFaire une demande de téléportation vers un joueur%nl%&2TPYES&7/&2TPACCEPT &7» &eVous permet d'accepté la demande de téléportation%nl%&cTPDENY &7» &ePermet de refuser la demande de téléportation")
send " "
json("%player%","&6» &3Message Privé||ttp:&7» &6Pour les utilisée faite /msg <pseudo>||sgt:/msg ")
send " "
json("%player%","&6» REPORT||ttp:&7» &2Entrer la commande /report <nom du joueur>||sgt:/report ")
if arg 1 is "staff":
player has permissions "soulgames.staff"
send " &c[&eCommande Moderation&c]"
send " "
json("%player%","&6» &bkick &7(kick un joueur du serveur)||ttp:&eChoisir le joueur a kick avec la raison /kick <joueur> <raison>||sgt:/kick ")
send " "
json("%player%","&6» &cBAN &7(Bannir un joueur du serveur)||sgt:/ban ")
send " "
json("%player%","&6» &eAnnonce||ttp: &7» &eFaire une annonce sur tout le serveur||sgt:/annonce ")
send " "
json("%player%","&6» &2Mute||ttp:&7» &6Mute un joueur selon le langage||sgt:/mute ")
send " "
json("%player%","&6» Fly||ttp:&7» &2Permet de fly pour surveiller un cheateur||sgt:/fly ")
send " "
json("%player%","&6» GOD||ttp:&7» Permet de pas recevoir de dégat pendant que vous surveiller un joueur||sgt:/god ")
send " "
json("%player%","&6» ClearChat||ttp:&7» &2Permet de clear le chat||sgt:/cc ")
if arg 1 is "reseau":
send " &b[&eLien&b]"
send " "
json("%player%","&6» &cYouTube||ttp:&7» &cSuivez le fondateur sur Youtube||url:https://www.youtube.com/channel/UCpybfRhrvpltMpVPX_B1spQ")
send " "
json("%player%","&6» &2Facebook||ttp:&7» &2Suivez nous sur Facebook||url:a venir")
send " "
json("%player%","&6» &bTwitter||ttp:&7» &bSuivez nous sur twitter||url:a venir")