Solved Player SafeTrade 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!

Selvati

Active Member
Jun 26, 2017
190
10
18
22
I AM TOO LAZY TO ATTEMP THIS SO I COPY PASTED MY HELP SECTION THREAD!

The Idea:
I ask the community to help me find the solution on how to make a player trading gui skript, where both players must agree/accept the trade to complete the transaction. If any player closes the inventory the items are returned to the correct players, and the trade is cancelled.

Basic Information:
♦ /trade command with variables such as accept, deny, send, <player>
♦ inventory is opened to both players in the trade using skript
♦ obviously not being able to steal the other's items.. hence the title safetrade
♦ either player closes trade inventory, the trade cancels, items return

EXAMPLE PICTURE BELOW:
505892ef69b7091f4610be1d7999ff5dbd61de8a-png.999

Any help at all is appreciated! ♥
Thanks in advance, Selvati.
 
I will work into this , i'll let you know here.
Thanks, I really appreciate it!
[doublepost=1501971252,1501971153][/doublepost]
I will work into this , i'll let you know here.
Here is a very nice video that I was actually hoping to replicate, but the author never released the code. I suggest checking it out. Thanks again!

[doublepost=1501971734][/doublepost]I'm sorry, just wanted to be clear that i would want to copy the concept of the trade inventory from the video, but not the clicking on a player to initiate the trade, I'd like that to be done by the example commands in the original post above, thanks again.. part 3000 :emoji_slight_smile:
 
Thanks, I really appreciate it!
[doublepost=1501971252,1501971153][/doublepost]
Here is a very nice video that I was actually hoping to replicate, but the author never released the code. I suggest checking it out. Thanks again!

[doublepost=1501971734][/doublepost]I'm sorry, just wanted to be clear that i would want to copy the concept of the trade inventory from the video, but not the clicking on a player to initiate the trade, I'd like that to be done by the example commands in the original post above, thanks again.. part 3000 :emoji_slight_smile:

I'll do it too , as a boolean option.
 
T
I'll do it too , as a boolean option.
That sounds great :emoji_slight_smile: !
[doublepost=1502658488,1501971933][/doublepost]bump ..
[doublepost=1502766869][/doublepost]Anyone have luck with this?
 
i found this on Turkish Skript forum. Maybe someone can remake this :'D Its bugs. cuz he is using the Umbaska GUI format

code_language.skript:
command /takas [<player>]:
    aliases: /t
    trigger:
        set {trade.%player%} to true
        set {tradeready.%player%} to false
      
        open chest with 3 rows named " %player-argument% ile takas yap?l?yor" to player
      
        format slot 3 of player with glass pane to be unstealable
        format slot 4 of player with glass pane to be unstealable
        format slot 5 of player with glass pane to be unstealable
        format slot 13 of player with glass pane to be unstealable
        format slot 21 of player with glass pane to be unstealable
        format slot 22 of player with glass pane to be unstealable
        format slot 23 of player with glass pane to be unstealable
      
        format slot 12 of player with air to be unstealable
        format slot 14 of player with air to be unstealable
      
        format slot 6 of player with air to be unstealable
        format slot 7 of player with air to be unstealable
        format slot 8 of player with air to be unstealable
        format slot 15 of player with air to be unstealable
        format slot 16 of player with air to be unstealable
        format slot 17 of player with air to be unstealable
        format slot 24 of player with air to be unstealable
        format slot 25 of player with air to be unstealable
        format slot 26 of player with air to be unstealable 
      
        set slot 0 of current inventory of player to {trade::%player%::0}
        set slot 1 of current inventory of player to {trade::%player%::1}
        set slot 2 of current inventory of player to {trade::%player%::2}
        set slot 9 of current inventory of player to {trade::%player%::9}
        set slot 10 of current inventory of player to {trade::%player%::10}
        set slot 11 of current inventory of player to {trade::%player%::11}
        set slot 18 of current inventory of player to {trade::%player%::18}
        set slot 19 of current inventory of player to {trade::%player%::19}
        set slot 20 of current inventory of player to {trade::%player%::20}
      
        if player-argument is set:
            set {trader.%player%} to player-argument
          
        while {trade.%player%} is true:
      
            set {trade::%player%::0} to slot 0 of current inventory of player
            set {trade::%player%::1} to slot 1 of current inventory of player
            set {trade::%player%::2} to slot 2 of current inventory of player
            set {trade::%player%::9} to slot 9 of current inventory of player
            set {trade::%player%::10} to slot 10 of current inventory of player
            set {trade::%player%::11} to slot 11 of current inventory of player
            set {trade::%player%::18} to slot 18 of current inventory of player
            set {trade::%player%::19} to slot 19 of current inventory of player
            set {trade::%player%::20} to slot 20 of current inventory of player

            if player-argument is set:
              
                if {tradeready.%player%} is true:
                    format slot 12 of player with green wool to run "tradeready %player%"
                else:
                    format slot 12 of player with red wool to run "tradeready %player%" 
              
                if {trader.%player-argument%} is player:                 
                    if {tradeready.%player-argument%} is true:

                        set slot 14 of current inventory of player to green wool
                      
                        if {tradeready.%player%} is true:
                      
                            set slot 6 of current inventory of player to {trade::%player-argument%::0}
                            set slot 7 of current inventory of player to {trade::%player-argument%::1}
                            set slot 8 of current inventory of player to {trade::%player-argument%::2}
                            set slot 15 of current inventory of player to {trade::%player-argument%::9}
                            set slot 16 of current inventory of player to {trade::%player-argument%::10}
                            set slot 17 of current inventory of player to {trade::%player-argument%::11}
                            set slot 24 of current inventory of player to {trade::%player-argument%::18}
                            set slot 25 of current inventory of player to {trade::%player-argument%::19}
                            set slot 26 of current inventory of player to {trade::%player-argument%::20}
                          
                            loop 20 times:
                                if {tradeready.%player-argument%} is true:
                                    if {tradeready.%player-argument%} is true:
                                        wait 0.25 seconds
                                    else:
                                        stop loop
                                else:
                                    stop loop

                            {tradeready.%player-argument%} is true
                            if {tradeready.%player%} is true:
                              
                                set {tradeready.%player%} to false
                                set {tradeready.%player-argument%} to false
                          
                                set slot 0 of current inventory of player to {trade::%player-argument%::0}
                                set slot 1 of current inventory of player to {trade::%player-argument%::1} 
                                set slot 2 of current inventory of player to {trade::%player-argument%::2}
                                set slot 9 of current inventory of player to {trade::%player-argument%::9} 
                                set slot 10 of current inventory of player to {trade::%player-argument%::10} 
                                set slot 11 of current inventory of player to {trade::%player-argument%::11} 
                                set slot 18 of current inventory of player to {trade::%player-argument%::18} 
                                set slot 19 of current inventory of player to {trade::%player-argument%::19} 
                                set slot 20 of current inventory of player to {trade::%player-argument%::20}
                          
                                set {trade::%player-argument%::0} to {trade::%player%::0}
                                set {trade::%player-argument%::1} to {trade::%player%::1}
                                set {trade::%player-argument%::2} to {trade::%player%::2}
                                set {trade::%player-argument%::9} to {trade::%player%::9}
                                set {trade::%player-argument%::10} to {trade::%player%::10}
                                set {trade::%player-argument%::11} to {trade::%player%::11}
                                set {trade::%player-argument%::18} to {trade::%player%::18}
                                set {trade::%player-argument%::19} to {trade::%player%::19}
                                set {trade::%player-argument%::20} to {trade::%player%::20}         
                          
                                set {trade::%player%::0} to slot 0 of current inventory of player
                                set {trade::%player%::1} to slot 1 of current inventory of player
                                set {trade::%player%::2} to slot 2 of current inventory of player
                                set {trade::%player%::9} to slot 9 of current inventory of player
                                set {trade::%player%::10} to slot 10 of current inventory of player
                                set {trade::%player%::11} to slot 11 of current inventory of player
                                set {trade::%player%::18} to slot 18 of current inventory of player
                                set {trade::%player%::19} to slot 19 of current inventory of player
                                set {trade::%player%::20} to slot 20 of current inventory of player
                          
                            else:

                                set slot 6 of current inventory of player to {trade::%player-argument%::0}
                                set slot 7 of current inventory of player to {trade::%player-argument%::1}
                                set slot 8 of current inventory of player to {trade::%player-argument%::2}
                                set slot 15 of current inventory of player to {trade::%player-argument%::9}
                                set slot 16 of current inventory of player to {trade::%player-argument%::10}
                                set slot 17 of current inventory of player to {trade::%player-argument%::11}
                                set slot 24 of current inventory of player to {trade::%player-argument%::18}
                                set slot 25 of current inventory of player to {trade::%player-argument%::19}
                                set slot 26 of current inventory of player to {trade::%player-argument%::20}
                              
                        else:
                            set slot 14 of current inventory of player to red wool
                      
                            set slot 6 of current inventory of player to {trade::%player-argument%::0}
                            set slot 7 of current inventory of player to {trade::%player-argument%::1}
                            set slot 8 of current inventory of player to {trade::%player-argument%::2}
                            set slot 15 of current inventory of player to {trade::%player-argument%::9}
                            set slot 16 of current inventory of player to {trade::%player-argument%::10}
                            set slot 17 of current inventory of player to {trade::%player-argument%::11}
                            set slot 24 of current inventory of player to {trade::%player-argument%::18}
                            set slot 25 of current inventory of player to {trade::%player-argument%::19}
                            set slot 26 of current inventory of player to {trade::%player-argument%::20}
                                                  
                    else:                     
                        set slot 14 of current inventory of player to red wool
                      
                        set slot 6 of current inventory of player to {trade::%player-argument%::0}
                        set slot 7 of current inventory of player to {trade::%player-argument%::1}
                        set slot 8 of current inventory of player to {trade::%player-argument%::2}
                        set slot 15 of current inventory of player to {trade::%player-argument%::9}
                        set slot 16 of current inventory of player to {trade::%player-argument%::10}
                        set slot 17 of current inventory of player to {trade::%player-argument%::11}
                        set slot 24 of current inventory of player to {trade::%player-argument%::18}
                        set slot 25 of current inventory of player to {trade::%player-argument%::19}
                        set slot 26 of current inventory of player to {trade::%player-argument%::20}     
                      
                else:                 
                    set slot 6 of current inventory of player to {trade::%player-argument%::0}
                    set slot 7 of current inventory of player to {trade::%player-argument%::1}
                    set slot 8 of current inventory of player to {trade::%player-argument%::2}
                    set slot 15 of current inventory of player to {trade::%player-argument%::9}
                    set slot 16 of current inventory of player to {trade::%player-argument%::10}
                    set slot 17 of current inventory of player to {trade::%player-argument%::11}
                    set slot 24 of current inventory of player to {trade::%player-argument%::18}
                    set slot 25 of current inventory of player to {trade::%player-argument%::19}
                    set slot 26 of current inventory of player to {trade::%player-argument%::20}

            else:
                stop loop
              
            wait 1 second 
      
        set slot 6 of current inventory of player to red stained glass pane
        set slot 7 of current inventory of player to red stained glass pane
        set slot 8 of current inventory of player to red stained glass pane
        set slot 15 of current inventory of player to red stained glass pane
        set slot 16 of current inventory of player to red stained glass pane
        set slot 17 of current inventory of player to red stained glass pane
        set slot 24 of current inventory of player to red stained glass pane
        set slot 25 of current inventory of player to red stained glass pane
        set slot 26 of current inventory of player to red stained glass pane
      
        set slot 12 of current inventory of player to red wool
        set slot 14 of current inventory of player to red wool


command /takaskabul <player>:
    executable by: console
    trigger:
        if {tradeready.%player-argument%} is true:
            set {tradeready.%player-argument%} to false
        else:
            set {tradeready.%player-argument%} to true
          
            if {trader.%{trader.%player-argument%}%} is player-argument:
                if {tradeready.%{trader.%player-argument%}%} is false:
                  
                    send "ยงa%player-argument% takas? kabul etti!" to {trader.%player-argument%}
                  
        send "%{tradeready.%player-argument%}%" to player-argument
          

command /takasiptal <player>:
    trigger:
        set {tradeready.%player-argument%} to false

on inventory close:
    if {trade.%player%} is true:

        set {trade::%player%::0} to slot 0 of current inventory of player
        set {trade::%player%::1} to slot 1 of current inventory of player
        set {trade::%player%::2} to slot 2 of current inventory of player
        set {trade::%player%::9} to slot 9 of current inventory of player
        set {trade::%player%::10} to slot 10 of current inventory of player
        set {trade::%player%::11} to slot 11 of current inventory of player
        set {trade::%player%::18} to slot 18 of current inventory of player
        set {trade::%player%::19} to slot 19 of current inventory of player
        set {trade::%player%::20} to slot 20 of current inventory of player             
      
        set {trade.%player%} to false
        set {tradeready.%player%} to false
      
        message "%{tradeready.%player%}%"

on inventory click:
    if {tradeready.%player%} is true:
        execute console command "takaskabul %player%"
 
i found this on Turkish Skript forum. Maybe someone can remake this :'D Its bugs. cuz he is using the Umbaska GUI format
If anything, I would rather start from scratch. That code is... terrible. The person who coded that should have used looping to reduce wasting time on the repetitive lines.
Here's example of what I am saying.
code_language.skript:
set {_n} to 0
loop 20 times:
    set slot {_n} of player to stone named "example"
    add 1 to {_n}
 
If anything, I would rather start from scratch. That code is... terrible. The person who coded that should have used looping to reduce wasting time on the repetitive lines.
Here's example of what I am saying.
code_language.skript:
set {_n} to 0
loop 20 times:
    set slot {_n} of player to stone named "example"
    add 1 to {_n}
Would you be willling to "recode" it lol just kidding

Thanks everyone whom'st've helped me out, greatly appreciated! <3
 
Would you be willling to "recode" it lol just kidding

Thanks everyone whom'st've helped me out, greatly appreciated! <3
i think i will recode it. :emoji_astonished: i think i know how do it. :emoji_grinning: give me maybe around 3hours
 
Wow... i think i did a lot exprience... :'D

Like i told, i think i need 3 hours. and now is near 3 hours past. :emoji_grinning:

Im not sure, if there some bugged. But for me WORKS VERY FINE! IM SO HAPPY TO SHARE THIS!

Oh yes i forgett a little to tell. i didn't add a "Request" btw "accept" system cuz its already a lot works for me. and i have enough works. Maybe you or someone can do this? :emoji_wink:

code_language.skript:
command /trade <player>:
    trigger:
        if arg-1 is set:
            if arg-1 is not player:
                open chest with 4 rows named "%player%    &eTrading    &r%arg-1%" to player
                open chest with 4 rows named "%arg-1%    &eTrading    &r%player%" to arg-1
                set {_t} to player
                loop 2 times:
                    set slot 3 of {_t}'s current inventory to orange stained glass pane named "&eUnready" with lore "&7Click here if you are finish"
                    set slot 5 of {_t}'s current inventory to orange stained glass pane named "&eUnready" with lore "&7He is not finished"
                    set {_s} to 4
                    loop 4 times:
                        if {_s} is 4:
                            set slot {_s} of {_t}'s current inventory to red stained glass pane named "&cCancel" with lore "&cIt will close the GUI"
                        set slot {_s} of {_t}'s current inventory to gray stained glass pane named "&r"
                        add 9 to {_s}
                    set {_t} to arg-1
                set {TradeM::%player%} to arg-1
                set {TradeM::%arg-1%} to player
                while name of player's current inventory contains "    &eTrading    ":
                    if name of arg-1's current inventory contains "    &eTrading    ":
                        set {_s} to 0
                        loop 4 times:
                            set slot 31 - {_s} of player's current inventory to gray stained glass pane named "&r"
                            set slot 31 - {_s} of arg-1's current inventory to gray stained glass pane named "&r"
                            add 9 to {_s}
                        set {_t} to player
                        set {_b} to arg-1
                        loop 2 times:
                            set {_s} to 0
                            loop 30 times:
                                set {Trade::%{_t}%::%{_s}%} to slot {_s} of {_t}'s current inventory
                                add 1 to {_s}
                                if {_s} is 3:
                                    set {_s} to 9
                                else if {_s} is 13:
                                    set {_s} to 18
                                else if {_s} is 22:
                                    set {_s} to 27
                                else if {_s} is 31:
                                    stop loop
                            set {_t} to arg-1
                            set {_b} to player
                        loop 2 times:
                            set {_s} to 6
                            set {_a} to 0
                            loop 30 times:
                                set slot {_s} of {_t}'s current inventory to {Trade::%{_b}%::%{_a}%}
                                add 1 to {_s}
                                add 1 to {_a}
                                if {_s} is 9:
                                    set {_s} to 14
                                    set {_a} to 9
                                else if {_s} is 18:
                                    set {_s} to 23
                                    set {_a} to 18
                                else if {_s} is 27:
                                    set {_s} to 32
                                    set {_a} to 27
                                else if {_s} is 36:
                                    stop loop
                            set {_t} to player
                            set {_b} to arg-1
                        wait 10 ticks
                        if {TradeR::%player%} is set:
                            if {TradeR::%arg-1%} is set:
                                send "You both accept it. Please don't do anythings in 3 seconds!"
                                send "You both accept it. Please don't do anythings in 3 seconds!" to arg-1
                                send "You can cancelt it, just press Green glass on your side!"
                                send "You can cancelt it, just press Green glass on your side!" to arg-1
                                set slot 31 of player's current inventory to green stained glass pane named "&a3..."
                                set slot 31 of arg-1's current inventory to green stained glass pane named "&a3..."
                                wait a seconds
                                {TradeR::%player%} is set
                                {TradeR::%arg-1%} is set
                                set slot 31 - 9 of player's current inventory to green stained glass pane named "&a2..."
                                set slot 31 - 9 of arg-1's current inventory to green stained glass pane named "&a2..."
                                wait a seconds
                                {TradeR::%player%} is set
                                {TradeR::%arg-1%} is set
                                set slot 31 - 18 of player's current inventory to green stained glass pane named "&a1..."
                                set slot 31 - 18 of arg-1's current inventory to green stained glass pane named "&a1..."
                                wait a seconds
                                {TradeR::%player%} is set
                                {TradeR::%arg-1%} is set
                                set slot 31 - 27 of player's current inventory to green stained glass pane named "&a0..."
                                set slot 31 - 27 of arg-1's current inventory to green stained glass pane named "&a0..."
                                wait a seconds
                                {TradeR::%player%} is set
                                {TradeR::%arg-1%} is set
                                set {DEAL::%player%} to true
                                set {DEAL::%arg-1%} to true
                                close player's inventory
                                close arg-1's inventory
                                send "&aDEAL!"
                                send "&aDEAL!" to arg-1
                    else:
                        close player's inventory
                close arg-1's inventory

on inventory close:
    if name of player's current inventory contains "    &eTrading    ":
        if {Deal::%player%} is set:
            set {_s} to 6
            loop 30 times:
                give slot {_s} of player's current inventory to player
                add 1 to {_s}
                if {_s} is 9:
                    set {_s} to 14
                else if {_s} is 18:
                    set {_s} to 23
                else if {_s} is 27:
                    set {_s} to 32
                else if {_s} is 36:
                    stop loop
            delete {Deal::%player%}
            delete {TradeM::%player%}
            delete {TradeR::%player%}
            delete {Trade::%player%::*}
        else:
            set {_s} to 0
            loop 30 times:
                give slot {_s} of player's current inventory to player
                add 1 to {_s}
                if {_s} is 3:
                    set {_s} to 9
                else if {_s} is 13:
                    set {_s} to 18
                else if {_s} is 22:
                    set {_s} to 27
                else if {_s} is 31:
                    stop loop
            delete {Deal::%player%}
            delete {TradeM::%player%}
            delete {TradeR::%player%}
            delete {Trade::%player%::*}
         
on inventory click:
    if name of player's current inventory contains "    &eTrading    ":
        if {TradeR::%player%} is set:
            if clicked slot is 3:
                set slot clicked slot of player's current inventory to orange stained glass pane named "&eUnready" with lore "&7Click here if you are finish"
                delete {TradeR::%player%}
                set slot 5 of {TradeM::%player%}'s current inventory to orange stained glass pane named "&eUnready" with lore "&7He is not finished"
                cancel event
            else:
                cancel event
                send "You can't move anythings while you are ready"
        else:
            if inventory type of clicked inventory is "CHEST":
                if clicked slot is between 3 and 8:
                    cancel event
                    if clicked slot is 3:
                        if clicked item is orange stained glass pane:
                            set slot clicked slot of player's current inventory to green stained glass pane named "&aYoure are READY!" with lore "&7Click here agin, if you want edit!"
                            set {TradeR::%player%} to true
                            set slot 5 of {TradeM::%player%}'s current inventory to green stained glass pane named "&aHe is READY!" with lore "&7If youre too ready, click on Orange Glass to accept deal!"
                        else:
                            set slot clicked slot of player's current inventory to orange stained glass pane named "&eUnready" with lore "&7Click here if you are finish"
                            delete {TradeR::%player%}
                            set slot 5 of {TradeM::%player%}'s current inventory to orange stained glass pane named "&eUnready" with lore "&7He is not finished"
                else if clicked slot is between 13 and 17:
                    cancel event
                else if clicked slot is between 22 and 26:
                    cancel event
                else if clicked slot is between 31 and 35:
                    cancel event


Maybe little screen
-Trading GUI
upload_2017-8-16_6-47-29.png


-One accepting trading (gartoon is aceppting (Right Minecraft))
upload_2017-8-16_6-47-57.png

While youre accepting, You can't move any items.

-If both accepting
upload_2017-8-16_6-48-59.png

Will countdown (Mid) change to green stained glass pane, if full green, will the gui close and you both get items
 
Last edited by a moderator: