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.

Drag and Drop Sell GUI

Discussion in 'Skript' started by Jerooski, May 3, 2020.

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

    Jerooski Member

    Joined:
    Apr 19, 2020
    Messages:
    16
    Likes Received:
    0
    Hello, I'm trying to make a GUI when /sell is done. You are supposed to drag and drop the listed items then they will be sold and give the player the set money. Here's what I got so far, I get no errors, the GUI opens correctly but when I drop the items and close the GUI, nothing happens.

    Note: Im using TUSKE as GUI.

    Code (Text):
    1. options:
    2.     p: &8&8SELL » #Prefix
    3.     iron: 30 #1 iron ingot sell price
    4.     gold: 40 #1 gold ingot sell price
    5.  
    6. command /sell:
    7.     trigger:
    8.         open virtual chest with 1 row named "&8Drag and drop to sell" to player
    9.          #here player's will drag and drop their items
    10.  
    11. on inventory click:
    12.     if inventory name of current inventory of player contains "&8Drag and drop to sell":
    13.         if slot 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 of current inventory of player is iron ingot:
    14.             set {_itemcounti} to number of all iron ingots in event-inventory
    15.             remove {_itemcounti} of iron ingots from event-inventory
    16.             add {@iron} * {_itemcounti} to the player's money
    17.             send "{@p} &8You sold %{_itemcounti}% iron ingot. &a%{@iron} * {_itemcounti}% was added to your wallet"
    18.  
    19.         else if slot 0 or 1 or 2 or 3 or 4 or 5 or 6 or 7 of current inventory of player is gold ingot:
    20.             set {_itemcountg} to number of all iron ingots in event-inventory
    21.             remove {_itemcountg} of iron ingots from event-inventory
    22.             add {@gold} * {_itemcountg} to the player's money
    23.             send "{@p} &8You sold %{_itemcountg}% gold ingot. &a%{@gold} * {_itemcountg}% was added to your wallet"
    24.         else:
    25.             send "{@p} &cYou are not allowed to sell that item!"
    26.    

    --- Double Post Merged, May 3, 2020, Original Post Date: May 3, 2020 ---
    bump
     
  2. AHappyLittleSloth

    Joined:
    Apr 22, 2020
    Messages:
    48
    Likes Received:
    4
    Here you go (Make sure to change the {_test} variable(It appears twice)):
    Code (Text):
    1. options:
    2.   p: &8&8SELL » #Prefix
    3.   iron: 30 #1 iron ingot sell price
    4.   gold: 40 #1 gold ingot sell price
    5.  
    6. command /sell:
    7.   trigger:
    8.     create a gui with virtual chest named "&8Drag and drop to sell" with 1 row
    9.     open last gui to player
    10.     #here player's will drag and drop their items
    11.  
    12. on inventory click:
    13.   if inventory name of current inventory of player contains "&8Drag and drop to sell":
    14.     if player's cursor slot is iron ingot:
    15.       wait 1 tick
    16.       set {_itemcounti} to amount of iron ingots in event-inventory
    17.       loop integers between 0 and 7:
    18.         set slot loop-integer of current inventory of player to air
    19.       add {@iron} * {_itemcounti} to {_test}#player's money
    20.       send "{@p} &7You sold &6%{_itemcounti}% &7iron ingot. &a%{@iron} * {_itemcounti}% &7was added to your wallet"
    21.     else if player's cursor slot is gold ingot:
    22.       wait 1 tick
    23.       set {_itemcountg} to amount of gold ingots in event-inventory
    24.       loop integers between 0 and 7:
    25.         set slot loop-integer of current inventory of player to air
    26.       add {@gold} * {_itemcountg} to {_test}#player's money
    27.       send "{@p} &7You sold &e%{_itemcountg}% &7gold ingot. &a%{@gold} * {_itemcountg}% &7was added to your wallet"
    28.     else:
    29.       send "{@p} &cYou are not allowed to sell that item!"
    30.       cancel event
    31.  
     
Thread Status:
Not open for further replies.

Share This Page

Loading...