Save player's inventory, and then return it - help!

  • 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 community!

    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.

NorteX

Member
Oct 21, 2017
3
0
0
Skript Version: 2.1
Skript Author: Njol
Minecraft Version: 1.5.2 (IK it's bit old, but yah I need to use this version)

---
Full Code:

code_language.skript:
set {lastinv::%player%} to player's inventory
set {lastinv::helm::%player%} to player's helmet
set {lastinv::chest::%player%} to player's chestplate
set {lastinv::legs::%player%} to player's legging
set {lastinv::boots::%player%} to player's boots
and then
set player's inventory to {lastinv::%player%}
set player's helmet to {lastinv.helm::%player%}
set player's chestplate to {lastinv.chest::%player%}
set player's leggings to {lastinv.legs::%player%}
set player's boots to {lastinv.boots::%player%}

Errors on Reload:

code_language.skript:
No errors, but it's just clearing the player's inventory when I try to return the items, even though I had some items before saving

Console Errors:

code_language.skript:
None

Other Useful Info:

Addons using (including versions):
No addons, clear Skript.

Troubleshooting:

Have you tried searching the docs? Yes
Have you tried searching the forums? Yes
 
I cant find the one I used before, but I whipped this up really quickly.

code_language.skript:
    set {_num} to 0
    loop 36 times:
        set {lastinv::%player%::%{_num}%} to slot {_num} of player's inventory
        add 1 to {_num}
    set {lastinv::helm::%player%} to player's helmet
    set {lastinv::chest::%player%} to player's chestplate
    set {lastinv::legs::%player%} to player's legging
    set {lastinv::boots::%player%} to player's boots


    set {_num} to 0
    loop 36 times:
        set slot {_num} of player's inventory to {lastinv::%player%::%{_num}%}
        add 1 to {_num}
    set player's helmet to {lastinv::helm::%player%}
    set player's chestplate to {lastinv::chest::%player%}
    set player's leggings to {lastinv::legs::%player%}
    set player's boots to {lastinv::boots::%player%}

EDIT:
As Simba said, I fixed the colon issue. ( I had originally copy/pasted your skript, and edited it, didn't notice the colon mistake)
 
Last edited by a moderator:
code_language.skript:
command /showinv:
  trigger:
    restore inventory of executor from {items::%executor%}
      
command /saveinv:
  trigger:
    set {items::%executor%} to executor's serialized inventory

Try this
 
I cant find the one I used before, but I whipped this up really quickly.

code_language.skript:
    set {_num} to 0
    loop 36 times:
        set {lastinv::%player%::%{_num}%} to slot {_num} of player's inventory
        add 1 to {_num}
    set {lastinv::helm::%player%} to player's helmet
    set {lastinv::chest::%player%} to player's chestplate
    set {lastinv::legs::%player%} to player's legging
    set {lastinv::boots::%player%} to player's boots


    set {_num} to 0
    loop 36 times:
        set slot {_num} of player's inventory to {lastinv::%player%::%{_num}%}
        add 1 to {_num}
    set player's helmet to {lastinv.helm::%player%}
    set player's chestplate to {lastinv.chest::%player%}
    set player's leggings to {lastinv.legs::%player%}
    set player's boots to {lastinv.boots::%player%}
I'll try, that should work.

code_language.skript:
command /showinv:
  trigger:
    restore inventory of executor from {items::%executor%}
     
command /saveinv:
  trigger:
    set {items::%executor%} to executor's serialized inventory

Try this
I'll try, but I think it wont work especially on 1.5.2... :emoji_stuck_out_tongue:
 
I'll try, that should work.


I'll try, but I think it wont work especially on 1.5.2... :emoji_stuck_out_tongue:
try to use spigot 1.8.8 and a plugin that adds support for 1.5.2 such as protocolsupport ¯\_(ツ)_/¯
 
Pretty sure you can't set a player's inventory to a list. You'll need to loop through the slot numbers and store the item in that slot indexed by the slot number. Also, you're saving the armor slots using lastinv.slot then loading it with lastinv::slot, so those need to match (i.e. change both to use :: instead of .)
 
Status
Not open for further replies.