options: tailleInventaire: 41 # 36 inventory + 4 equipment + 1 second hand messagePreChangement: "&7Changement d'inventaire..." messagePostChargement: "&7&l%{_n1}%&7 objet%{_pluriel1}%&7 unique%{_pluriel1}%&7 sauvegardé%{_pluriel1}%&7 et &l%{_n2}%&7 objet%{_pluriel2}%&7 unique%{_pluriel2}%&7 chargé%{_pluriel2}%&7." on load: ScriptList("add", script) on unload: ScriptList("remove", script) # allows to save the inventory of a player in a specific gamemode # in the database and to return the number of saved items function inventaire(mode: text, player: player, gamemode: text) :: number: set {_uuid} to uuid of {_player} set {_count} and {_nombreItems} to 0 if {_mode} is "chargement": clear inventory of {_player} loop {@tailleInventaire} times: if {_mode} is "chargement": set {_item} to {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} # récupération item set slot {_count} of inventory of {_player} to {_item} # enrengistrement item else if {_mode} is "sauvegarde": delete {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} # suppression de l'ancienne donnée set {_item} to slot {_count} of inventory of {_player} set {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} to {_item} if "%{_item}%" is not "" or "air" or "0 air": # air quand inventaire vide, 0 air quand main gauche vide et quand équipement vide add 1 to {_nombreItems} add 1 to {_count} return {_nombreItems} # triggered when switching from/to survival gamemode on gamemode change: if old gamemode of player is survival: set {_n1} to inventaire("sauvegarde", player, "survival") set {_pluriel1} to pluriel({_n1}) send {@messagePreChangement} set {_n2} to inventaire("chargement", player, "creative") set {_pluriel2} to pluriel({_n2}) send {@messagePostChargement} else if gamemode of player is survival: set {_n1} to inventaire("sauvegarde", player, "creative") set {_pluriel1} to pluriel({_n1}) send {@messagePreChangement} set {_n2} to inventaire("chargement", player, "survival") set {_pluriel2} to pluriel({_n2}) send {@messagePostChargement}