Loops and enchants

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

Marsbar

Active Member
Mar 31, 2019
131
4
18
18
Hi im trying to make a skript that sells everything in player's inventory that not are enchanted. Please help me:emoji_slight_smile:
Code:
i got some try:
Code:
command /Test27:
    trigger:
        loop all items in player's inventory:
            loop 2304 times:
                set {_item} to id of loop-item
                if {_item} is 267:
                    if player have 1 of loop-item in inventory:
                        set {_ite} to loop-item
                        loop enchantments of loop-item:
                            broadcast "%loop-enchantment%"
                            set {_item::*} to loop-item
                            broadcast "%{_item::*}%"
                        if {_ite} is {_item::*}:
                            set {}
                        else:
                            remove 1 of loop-item from player's inventory
                            add 1 to player's balance
                            broadcast "dsgdhgfvbdhjfhvdfk"
                    else:
                        send "t"
                        stop

command /Test28:
    trigger:
        loop all items in player's inventory:
            if loop-item is enchanted:
                remove loop-item from player's inventory
                set {_item.%{count}%} to loop-item
                add 1 to {count}
            else:
        set {_count} to {count}
        loop {_count} times:
            send "t"
            set {_items} to {_item.%{count}%} parsed as a item
            give {_items} to player
            add 1 to {_count}

command /Test29:
    trigger:
        loop all items in player's inventory:
            loop 2304 times:
       
                if loop-item is enchanted:
                    add 1 to {count}
                    set {ite.%player%.%{count}%} to loop-item
                    remove loop-item from player
                    set {_hehe.%loop-item%} to true
           


command /Sell:
    permission: Vagt
    permission message: &4Du er ikke vagt!
    trigger:
        loop all items in player's inventory:
            broadcast "ty"
            loop 2304 times:
                send "g"
                if loop-item is enchanted:
                    send "dgfgb"
                    set {_hehe.%loop-item%} to loop-item
                    stop loop
            wait 5 seconds
            send "tcf"
            loop {_hehe::*}:
                give loop-value to player


Edit:
some extra code:
Code:
command /Test28:
    trigger:
        loop all items in player's inventory:
            if loop-item is iron sword:
                if loop-item isn't enchanted:
                    remove loop-item from player
                    add 8 to {løn.%player%}
                else:
                    set {_tor} to loop-item
                    send "%{_tor}%"
                    remove loop-item from the player
                    wait 1 ticks
                    give {_tor} to player
        if {løn.%player%} isn't set:
            send "&2&LSell || &ayou got $0"
        else:
            send "&2&LSell || &ayou got $%{løn.%player%}%"
            add {løn.%player%} to player's balance
        clear {løn.%player%}
 
Last edited:
Code:
command /sell:
    trigger:
        set {_sellAmount} to 0
        loop all items in inventory of player:
            if loop-item is enchanted:
                loop (amount of item loop-item) times:
                    add 1 to {_sellAmount}
                    remove loop-item from player's inventory
        broadcast "&eTotal enchanted items: %{_sellAmount}%"
I don't really understand your code (some of the stuff seems arbitrary to me?) but hopefully this will point you in the right direction. I definitely do not understand why you would loop 2304 times that is truly a mystery to me lol.

p.s. my code assumes that the items that are enchanted can also be stacked otherwise it would be better to simplify this a little!
 
Code:
command /sell:
    trigger:
        set {_sellAmount} to 0
        loop all items in inventory of player:
            if loop-item is enchanted:
                loop (amount of item loop-item) times:
                    add 1 to {_sellAmount}
                    remove loop-item from player's inventory
        broadcast "&eTotal enchanted items: %{_sellAmount}%"
I don't really understand your code (some of the stuff seems arbitrary to me?) but hopefully this will point you in the right direction. I definitely do not understand why you would loop 2304 times that is truly a mystery to me lol.

p.s. my code assumes that the items that are enchanted can also be stacked otherwise it would be better to simplify this a little!
That not really what im looking for. in the extra code i try to do so it sell the loop-item if it not is enchanted, but it just remove the other sword
{løn.%player%} is just my language for {earnedmoney.%player%}
 
Try this:
Code:
command /sell:
    trigger:
        loop 36 times:
            set {_i} to loop-number - 1
            slot {_i} of player is enchanted
            add (item amount of slot {_i} of player) to {_amount}
            set slot {_i} of player to air
        add {_amount} to {løn.%player%}
        message "Sold %{_amount} ? 0% items"
 
Try this:
Code:
command /sell:
    trigger:
        loop 36 times:
            set {_i} to loop-number - 1
            slot {_i} of player is enchanted
            add (item amount of slot {_i} of player) to {_amount}
            set slot {_i} of player to air
        add {_amount} to {løn.%player%}
        message "Sold %{_amount} ? 0% items"
wouldn't using filters work?
code_language.skript:
        set {_list::*} to all items in player' inventory where [item input is enchanted]
        add amount of {_list::*} in player' inventory to {_a}
 
It don't really work.. Can we let the other code i writed first be and just try with this code:
Code:
command /Test28:
    trigger:
        loop all items in player's inventory:
            if loop-item is iron sword:
                set {_slot} to slot of loop-item
                set {_item} to loop-item
                if loop-item isn't enchanted:
                    remove loop-item from player
                    add 8 to {løn.%player%}
                else:
                    set {_tor} to loop-item
                    send "%{_tor}%"
                    remove loop-item from the player
                    wait 1 ticks
                    give {_tor} to player
        if {løn.%player%} isn't set:
            send "&2&LSell || &aDu tjente $0"
        else:
            send "&2&LSell || &aDu tjente $%{løn.%player%}%"
            add {løn.%player%} to player's balance
        clear {løn.%player%}


It is like i want it just take the "not" enchanted iron sword when i wan't it to take the the enchanted sword. I add a video about it soon.. Sorry for music in it!
 
Last edited:
Status
Not open for further replies.