1. 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!

  2. LOOKING FOR A VERSION OF SKRIPT?

    You can always check out our Wiki for downloads and any other information about Skript!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Loops and enchants

Discussion in 'Skript' started by Marsbar, Apr 4, 2019.

Thread Status:
Not open for further replies.
  1. Marsbar

    Marsbar Active Member

    Joined:
    Mar 31, 2019
    Messages:
    131
    Likes Received:
    4
    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 (Text):
    1. command /Test27:
    2.     trigger:
    3.         loop all items in player's inventory:
    4.             loop 2304 times:
    5.                 set {_item} to id of loop-item
    6.                 if {_item} is 267:
    7.                     if player have 1 of loop-item in inventory:
    8.                         set {_ite} to loop-item
    9.                         loop enchantments of loop-item:
    10.                             broadcast "%loop-enchantment%"
    11.                             set {_item::*} to loop-item
    12.                             broadcast "%{_item::*}%"
    13.                         if {_ite} is {_item::*}:
    14.                             set {}
    15.                         else:
    16.                             remove 1 of loop-item from player's inventory
    17.                             add 1 to player's balance
    18.                             broadcast "dsgdhgfvbdhjfhvdfk"
    19.                     else:
    20.                         send "t"
    21.                         stop
    22.  
    23. command /Test28:
    24.     trigger:
    25.         loop all items in player's inventory:
    26.             if loop-item is enchanted:
    27.                 remove loop-item from player's inventory
    28.                 set {_item.%{count}%} to loop-item
    29.                 add 1 to {count}
    30.             else:
    31.         set {_count} to {count}
    32.         loop {_count} times:
    33.             send "t"
    34.             set {_items} to {_item.%{count}%} parsed as a item
    35.             give {_items} to player
    36.             add 1 to {_count}
    37.  
    38. command /Test29:
    39.     trigger:
    40.         loop all items in player's inventory:
    41.             loop 2304 times:
    42.        
    43.                 if loop-item is enchanted:
    44.                     add 1 to {count}
    45.                     set {ite.%player%.%{count}%} to loop-item
    46.                     remove loop-item from player
    47.                     set {_hehe.%loop-item%} to true
    48.            
    49.  
    50.  
    51. command /Sell:
    52.     permission: Vagt
    53.     permission message: &4Du er ikke vagt!
    54.     trigger:
    55.         loop all items in player's inventory:
    56.             broadcast "ty"
    57.             loop 2304 times:
    58.                 send "g"
    59.                 if loop-item is enchanted:
    60.                     send "dgfgb"
    61.                     set {_hehe.%loop-item%} to loop-item
    62.                     stop loop
    63.             wait 5 seconds
    64.             send "tcf"
    65.             loop {_hehe::*}:
    66.                 give loop-value to player

    Edit:
    some extra code:
    Code (Text):
    1.  
    2. command /Test28:
    3.     trigger:
    4.         loop all items in player's inventory:
    5.             if loop-item is iron sword:
    6.                 if loop-item isn't enchanted:
    7.                     remove loop-item from player
    8.                     add 8 to {løn.%player%}
    9.                 else:
    10.                     set {_tor} to loop-item
    11.                     send "%{_tor}%"
    12.                     remove loop-item from the player
    13.                     wait 1 ticks
    14.                     give {_tor} to player
    15.         if {løn.%player%} isn't set:
    16.             send "&2&LSell || &ayou got $0"
    17.         else:
    18.             send "&2&LSell || &ayou got $%{løn.%player%}%"
    19.             add {løn.%player%} to player's balance
    20.         clear {løn.%player%}
     
    #1 Marsbar, Apr 4, 2019
    Last edited: Apr 4, 2019
  2. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
  3. Noblesuntzu

    Noblesuntzu Active Member

    Joined:
    Feb 18, 2017
    Messages:
    63
    Likes Received:
    4
    Code (Text):
    1. command /sell:
    2.     trigger:
    3.         set {_sellAmount} to 0
    4.         loop all items in inventory of player:
    5.             if loop-item is enchanted:
    6.                 loop (amount of item loop-item) times:
    7.                     add 1 to {_sellAmount}
    8.                     remove loop-item from player's inventory
    9.         broadcast "&eTotal enchanted items: %{_sellAmount}%"
    10.  
    11.  
    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!
     
  4. Marsbar

    Marsbar Active Member

    Joined:
    Mar 31, 2019
    Messages:
    131
    Likes Received:
    4
    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%}
     
  5. TPGamesNL

    Supporter Addon Developer Dev Programme

    Joined:
    Jan 20, 2018
    Messages:
    1,501
    Likes Received:
    107
    Medals:
    Try this:
    Code (Text):
    1. command /sell:
    2.     trigger:
    3.         loop 36 times:
    4.             set {_i} to loop-number - 1
    5.             slot {_i} of player is enchanted
    6.             add (item amount of slot {_i} of player) to {_amount}
    7.             set slot {_i} of player to air
    8.         add {_amount} to {løn.%player%}
    9.         message "Sold %{_amount} ? 0% items"
     
  6. Runakai

    Moderator Supporter

    Joined:
    Apr 27, 2018
    Messages:
    497
    Likes Received:
    31
    wouldn't using filters work?
    Code (Skript):
    1.  
    2.         set {_list::*} to all items in player' inventory where [item input is enchanted]
    3.         add amount of {_list::*} in player' inventory to {_a}
     
    • Agree Agree x 1
    • Winner Winner x 1
  7. Marsbar

    Marsbar Active Member

    Joined:
    Mar 31, 2019
    Messages:
    131
    Likes Received:
    4
    It don't really work.. Can we let the other code i writed first be and just try with this code:
    Code (Text):
    1. command /Test28:
    2.     trigger:
    3.         loop all items in player's inventory:
    4.             if loop-item is iron sword:
    5.                 set {_slot} to slot of loop-item
    6.                 set {_item} to loop-item
    7.                 if loop-item isn't enchanted:
    8.                     remove loop-item from player
    9.                     add 8 to {løn.%player%}
    10.                 else:
    11.                     set {_tor} to loop-item
    12.                     send "%{_tor}%"
    13.                     remove loop-item from the player
    14.                     wait 1 ticks
    15.                     give {_tor} to player
    16.         if {løn.%player%} isn't set:
    17.             send "&2&LSell || &aDu tjente $0"
    18.         else:
    19.             send "&2&LSell || &aDu tjente $%{løn.%player%}%"
    20.             add {løn.%player%} to player's balance
    21.         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!
     
    #7 Marsbar, Apr 6, 2019
    Last edited: Apr 6, 2019
Thread Status:
Not open for further replies.

Share This Page

Loading...