2021-07-01 03:01:20 +02:00
|
|
|
options:
|
2021-11-14 03:13:58 +01:00
|
|
|
tailleInventaire: 41 # 36 inventory + 4 equipment + 1 second hand
|
2021-07-01 20:41:49 +02:00
|
|
|
messagePreChangement: "&7Changement d'inventaire..."
|
2021-07-02 03:19:22 +02:00
|
|
|
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."
|
2021-07-01 03:01:20 +02:00
|
|
|
|
2021-06-30 21:58:41 +02:00
|
|
|
on load:
|
|
|
|
ScriptList("add", script)
|
|
|
|
on unload:
|
|
|
|
ScriptList("remove", script)
|
2021-07-01 03:01:20 +02:00
|
|
|
|
2021-11-14 03:13:58 +01:00
|
|
|
# allows to save the inventory of a player in a specific gamemode
|
|
|
|
# in the database and to return the number of saved items
|
2021-07-01 20:41:49 +02:00
|
|
|
function inventaire(mode: text, player: player, gamemode: text) :: number:
|
2021-07-01 03:01:20 +02:00
|
|
|
set {_uuid} to uuid of {_player}
|
2021-07-01 20:41:49 +02:00
|
|
|
set {_count} and {_nombreItems} to 0
|
|
|
|
if {_mode} is "chargement":
|
|
|
|
clear inventory of {_player}
|
2021-07-01 03:01:20 +02:00
|
|
|
loop {@tailleInventaire} times:
|
2021-07-01 20:41:49 +02:00
|
|
|
if {_mode} is "chargement":
|
2021-07-02 03:00:51 +02:00
|
|
|
set {_item} to {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} # récupération item
|
|
|
|
set slot {_count} of inventory of {_player} to {_item} # enrengistrement item
|
2021-07-01 20:41:49 +02:00
|
|
|
else if {_mode} is "sauvegarde":
|
2021-07-02 03:00:51 +02:00
|
|
|
delete {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} # suppression de l'ancienne donnée
|
2021-07-01 22:20:16 +02:00
|
|
|
set {_item} to slot {_count} of inventory of {_player}
|
2021-07-01 20:41:49 +02:00
|
|
|
set {inv.%{_uuid}%.%{_gamemode}%::%{_count}%} to {_item}
|
2021-07-02 03:00:51 +02:00
|
|
|
if "%{_item}%" is not "<none>" or "air" or "0 air": # air quand inventaire vide, 0 air quand main gauche vide et <none> quand équipement vide
|
|
|
|
add 1 to {_nombreItems}
|
2021-07-01 03:01:20 +02:00
|
|
|
add 1 to {_count}
|
2021-07-01 20:41:49 +02:00
|
|
|
return {_nombreItems}
|
2021-07-01 03:01:20 +02:00
|
|
|
|
2021-11-14 03:13:58 +01:00
|
|
|
# triggered when switching from/to survival gamemode
|
2021-07-01 03:01:20 +02:00
|
|
|
on gamemode change:
|
|
|
|
if old gamemode of player is survival:
|
2021-07-01 22:20:16 +02:00
|
|
|
set {_n1} to inventaire("sauvegarde", player, "survival")
|
|
|
|
set {_pluriel1} to pluriel({_n1})
|
2021-07-01 20:41:49 +02:00
|
|
|
send {@messagePreChangement}
|
|
|
|
set {_n2} to inventaire("chargement", player, "creative")
|
2021-07-01 22:20:16 +02:00
|
|
|
set {_pluriel2} to pluriel({_n2})
|
2021-07-01 20:41:49 +02:00
|
|
|
send {@messagePostChargement}
|
2021-07-01 03:01:20 +02:00
|
|
|
else if gamemode of player is survival:
|
2021-07-01 20:41:49 +02:00
|
|
|
set {_n1} to inventaire("sauvegarde", player, "creative")
|
2021-07-01 22:20:16 +02:00
|
|
|
set {_pluriel1} to pluriel({_n1})
|
2021-07-01 20:41:49 +02:00
|
|
|
send {@messagePreChangement}
|
2021-07-01 22:20:16 +02:00
|
|
|
set {_n2} to inventaire("chargement", player, "survival")
|
|
|
|
set {_pluriel2} to pluriel({_n2})
|
2021-07-01 20:41:49 +02:00
|
|
|
send {@messagePostChargement}
|