Save a players inventory

  • 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.

CatsAreit

New Member
Feb 11, 2017
9
0
0
I was trying to make a Moderator Mode Skript, and when you go into Moderator Mode, I want it to save their last inventory, so when they disable Moderator Mode, they get their last inventory given back.

Could someone help me?:


All of the skript code:

Code:
command /mod:
    trigger:
        set player's inventory to {lastinv.%player%}
        player command "/vanish on"
        player command "/fly on"
        clear player's inventory
        give player compass
        message "&8&l(&3&lVexorModMode&8&l) &aStaff mode has been enabled! Use /v to un-ModMode"
        wait 1 tick
        set helmet slot of player to a diamond helmet
        set chestplate slot of player to a leather chestplate
        set legging slot of player to leather chestplates
        set boot slot of player to diamond boots
        give player book named "&cInventory"
        give player ice named "&bFreeze"
        give player blue dye named "&bVanish"
    

on right click on player:
        name of player's held item contains "&cInventory"
        execute player command "/invsee %clicked player%"

on right click on player:
        name of player's held item contains "&bFreeze"
        execute player command "/freeze %clicked player%"

command /freeze [<player>]:
    trigger:
        if argument 1 is not set:
            message "&c/freeze <target>"
        if argument 1 is set:
            set {freeze.%arg-1%} to true
            message "&eYou have been frozen. Do not logout or you will be &4&lBANNED&e." to argument 1
            apply blindness to argument 1 for 100 days
            apply slowness to argument 1 for 100 days
            message "&c%arg-1% has been frozen by a staff member."
          
on any movement:
    {freeze.%player%} is true:
        cancel event

command /unfreeze [<player>]:
    trigger:
        if argument 1 is not set:
            message "&c/unfreeze <target>"
        if argument 1 is set:
            set {freeze.%arg-1%} to false
            message "&aYou have been unfrozen." to argument 1
            console command "/effect %arg-1% clear"
            message "&a%arg-1% has been unfrozen by a staff member"

on right click:
    player is holding blue dye named "&bVanish":
        player command "/vanish"


command /unmod:
    trigger:
        clear the player's inventory
        message "&8&l(&3&lVexorModMode&8&l) &aYour Mod Mode has been disabled."
        player command "/v off"
        player command "/fly off"
        give player {lastinv.%player%}


There are no errors
 
You can add the inventory items to a list variable on the use of the command, and then loop it again after to pull the items back out.
code_language.skript:
loop all items in player's inventory:
    add loop-item to {Inventory:%player%::*}
That doesn't include armor slots, you'd have to add those to the list manually
 
You can add the inventory items to a list variable on the use of the command, and then loop it again after to pull the items back out.
code_language.skript:
loop all items in player's inventory:
    add loop-item to {Inventory:%player%::*}
That doesn't include armor slots, you'd have to add those to the list manually
No need to loop here. If you can loop it, you can just add it directly
code_language.skript:
set {inventory::%player's uuid%::*} to all items in player's inventory
 
  • Like
Reactions: Wynnevir
Status
Not open for further replies.