Help with the script

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

Velmat

Member
Jun 4, 2024
3
0
1
22
Hi all.

I'm new to the Skript theme, so I have very little experience writing my own small projects.
I need your help.

How to make sure that if a player writes the command /randominv <player>, the locations of the selected player’s resources in the inventory are changed to random

(Sorry for my bad English)
 
Create a list of the player's items, shuffle the list, clear the player's inventory, loop and set slots to items
 
I apologize in advance for the stupidity of my actions and thoughts, but I don’t fully understand all this. Sorry

command /randominv [<player>]:
trigger:
loop all items in arg-1's inventory:
add items of arg-1 to {item-list}
set {obj} to a random object out of {item-list}
add {obj} to {_shuffledlist::*}
clear arg-1's inventory
set slots to {_shuffledlist::*}
 
I haven't tested this code but I tried to fix your code. some issues to point out were trying to add items to a non list variable (ex: {notlistvar} {islistvar::*}). also you shiffled your varialbe incorrectly and tried to set multiple slots at once (idk if you can do that but that's not how if you can)
AppleScript:
command /randominv <player=%player%>:
    trigger:
        loop all items in arg-1's inventory:
            add loop-item to {_item-list::*}
        loop 36 - size of {_item-list::*} times:
            add air to {_item-list::*}
        set {_item-list::*} to shuffled {_item-list::*}
        clear arg-1's inventory
        loop {_item-list::*}:
            set slot (loop-index - 1) of arg-1 to loop-value