Drag and Drop Sell GUI

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

Jerooski

Member
Apr 19, 2020
16
0
0
25
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:
options:
    p: &8&8SELL » #Prefix
    iron: 30 #1 iron ingot sell price
    gold: 40 #1 gold ingot sell price

command /sell:
    trigger:
        open virtual chest with 1 row named "&8Drag and drop to sell" to player
         #here player's will drag and drop their items

on inventory click:
    if inventory name of current inventory of player contains "&8Drag and drop to sell":
        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:
            set {_itemcounti} to number of all iron ingots in event-inventory
            remove {_itemcounti} of iron ingots from event-inventory
            add {@iron} * {_itemcounti} to the player's money
            send "{@p} &8You sold %{_itemcounti}% iron ingot. &a%{@iron} * {_itemcounti}% was added to your wallet"

        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:
            set {_itemcountg} to number of all iron ingots in event-inventory
            remove {_itemcountg} of iron ingots from event-inventory
            add {@gold} * {_itemcountg} to the player's money
            send "{@p} &8You sold %{_itemcountg}% gold ingot. &a%{@gold} * {_itemcountg}% was added to your wallet"
        else:
            send "{@p} &cYou are not allowed to sell that item!"
[doublepost=1588529020,1588487363][/doublepost]bump
 
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:
options:
    p: &8&8SELL » #Prefix
    iron: 30 #1 iron ingot sell price
    gold: 40 #1 gold ingot sell price

command /sell:
    trigger:
        open virtual chest with 1 row named "&8Drag and drop to sell" to player
         #here player's will drag and drop their items

on inventory click:
    if inventory name of current inventory of player contains "&8Drag and drop to sell":
        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:
            set {_itemcounti} to number of all iron ingots in event-inventory
            remove {_itemcounti} of iron ingots from event-inventory
            add {@iron} * {_itemcounti} to the player's money
            send "{@p} &8You sold %{_itemcounti}% iron ingot. &a%{@iron} * {_itemcounti}% was added to your wallet"

        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:
            set {_itemcountg} to number of all iron ingots in event-inventory
            remove {_itemcountg} of iron ingots from event-inventory
            add {@gold} * {_itemcountg} to the player's money
            send "{@p} &8You sold %{_itemcountg}% gold ingot. &a%{@gold} * {_itemcountg}% was added to your wallet"
        else:
            send "{@p} &cYou are not allowed to sell that item!"
[doublepost=1588529020,1588487363][/doublepost]bump

Here you go (Make sure to change the {_test} variable(It appears twice)):
Code:
options:
  p: &8&8SELL » #Prefix
  iron: 30 #1 iron ingot sell price
  gold: 40 #1 gold ingot sell price

command /sell:
  trigger:
    create a gui with virtual chest named "&8Drag and drop to sell" with 1 row
    open last gui to player
    #here player's will drag and drop their items

on inventory click:
  if inventory name of current inventory of player contains "&8Drag and drop to sell":
    if player's cursor slot is iron ingot:
      wait 1 tick
      set {_itemcounti} to amount of iron ingots in event-inventory
      loop integers between 0 and 7:
        set slot loop-integer of current inventory of player to air
      add {@iron} * {_itemcounti} to {_test}#player's money
      send "{@p} &7You sold &6%{_itemcounti}% &7iron ingot. &a%{@iron} * {_itemcounti}% &7was added to your wallet"
    else if player's cursor slot is gold ingot:
      wait 1 tick
      set {_itemcountg} to amount of gold ingots in event-inventory
      loop integers between 0 and 7:
        set slot loop-integer of current inventory of player to air
      add {@gold} * {_itemcountg} to {_test}#player's money
      send "{@p} &7You sold &e%{_itemcountg}% &7gold ingot. &a%{@gold} * {_itemcountg}% &7was added to your wallet"
    else:
      send "{@p} &cYou are not allowed to sell that item!"
      cancel event
 
Status
Not open for further replies.