Solved How to get an item in a slot and set it in a variable?

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

Frqzz_

Member
Jun 25, 2021
3
0
1
I am trying to do this but it doesnt work!
Here is my code:


Code:
command /saveinventory <string> <string>:
    permission: op
    permission message: "&c&lPCloudMine&r >> &cYou do not have the permissions to execute this command!"
    aliases: /saveinv
    trigger:
        if arg-1 is "save":
            if arg-2 is set:
                if size of {%player's uuid%::%arg-2%::*} - 1 is greater than 0:
                    send "&cError! The inventory %arg-2% is already used!"
                else:
                    loop 35 times:
                        add slot loop-number to {%player's uuid%::%arg-2%::_%loop-number%::*}
                    loop 4 times:
                        add slot loop-number + 100 to {%player's uuid%::%arg-2%::_%loop-number + 100%::*}
                    send "&a&l[✓] &fSaved &7&o%size of {%player's uuid%::%arg-2%::*} - 1%&r&f items."
        if arg-1 is "load":
            if size of {%player's uuid%::%arg-2%::*} - 1 is greater than 0:
                loop 35 times:
                    set slot loop-number of player to {%player's uuid%::%arg-2%::%loop-number%::*}
                loop 4 times:
                    set slot loop-number + 100 of player to {%player's uuid%::%arg-2%::%loop-number + 100%::*}
                send "&a&l[✓] &fFilled your inventory!"
            else:
                send "&cError! The inventory %arg-2% is empty!"
        if arg-1 is "remove":
            if {%player's uuid%.%arg-2%} - 1 is set:
                delete {%player's uuid%.%arg-2%}
                send "&a&l[-] &fRemoved %arg-2%!"
            else:
                send "&cError! The inventory %arg-2% doesn't exist!"
        if arg-1 is "list":
            send {%player's uuid%::*}
            send "&a&l[✓] &fDone!"

i am getting the error in:


Code:
                    loop 35 times:
                        add slot loop-number to {%player's uuid%::%arg-2%::_%loop-number%::*}
                    loop 4 times:
                        add slot loop-number + 100 to {%player's uuid%::%arg-2%::_%loop-number + 100%::*}
                    send "&a&l[✓] &fSaved &7&o%size of {%player's uuid%::%arg-2%::*} - 1%&r&f items."

Please help me!
 
set {item::%player%} to slot 2 of player's inventory

^ this will set the variable to the item in slot 2 of player's inventory.
 
set {item::%player%} to slot 2 of player's inventory

^ this will set the variable to the item in slot 2 of player's inventory.
Hey! Thank you but ive solved it myself. It is exactly how i corrected my mistake. But still, thanks! :emoji_grinning:
 
Status
Not open for further replies.