Save inventory of player

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

Aralwen

Active Member
May 26, 2017
164
14
18
25
Hey,
I would like to make sure to save a player's inventory in a tag, but also his armor
Currently the inventory is saved, but not the armor

My code:

code_language.skript:
command /showinv:
    trigger:
        restore inventory of player from {Stuff}
        set {_inv} to chest with 6 rows named "Stuff"
        set {_inv}'s serialized contents to {Stuff}
        open {_inv} to player
       
command /saveinv:
    set {Stuff} to player's serialized inventory
    send "&a&l[✓] &fSaved"

Thank you :emoji_slight_smile:
 
Hey,
I would like to make sure to save a player's inventory in a tag, but also his armor
Currently the inventory is saved, but not the armor

My code:

code_language.skript:
command /showinv:
    trigger:
        restore inventory of player from {Stuff}
        set {_inv} to chest with 6 rows named "Stuff"
        set {_inv}'s serialized contents to {Stuff}
        open {_inv} to player
      
command /saveinv:
    set {Stuff} to player's serialized inventory
    send "&a&l[✓] &fSaved"

Thank you :emoji_slight_smile:


Try this

code_language.skript:
command /showinv:
    trigger:
        if {stuff:%player%::*} exists:
            open chest with 6 rows named "Saved Inventory" to player
            set {_slot} to -1
            loop {stuff:%player%::*}:
                add 1 to {_slot}
                set slot {_slot} of player's current inventory to loop-value
                
        
        
        
command /saveinv:
    trigger:
        loop all items in player's inventory:
            add loop-item to {stuff:%player%::*}
        send "&a&l[✓] &fSaved &7&o%size of {stuff:%player%::*}%&r&f items."
 
  • Like
Reactions: Aralwen
Try this

code_language.skript:
command /showinv:
    trigger:
        if {stuff:%player%::*} exists:
            open chest with 6 rows named "Saved Inventory" to player
            set {_slot} to -1
            loop {stuff:%player%::*}:
                add 1 to {_slot}
                set slot {_slot} of player's current inventory to loop-value
              
      
      
      
command /saveinv:
    trigger:
        loop all items in player's inventory:
            add loop-item to {stuff:%player%::*}
        send "&a&l[✓] &fSaved &7&o%size of {stuff:%player%::*}%&r&f items."
Hello, thank's for help ! It works perfectly, but it does not save the armor of player :/
 
Status
Not open for further replies.