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!

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

Script Revised little trading script 2

Revised trading script

  1. Juc70
    Contributors:
    Creep_x, me and SkUnity Docs
    Supported Minecraft Versions:
    • 1.13
    [​IMG]
    My older trading script: Bad Little Trading Script
    Description
    A script that allows the trading of items safely using an in game gui. It has multiple anti-scam measures and some editable properties such as item blacklist. Gui has all new clean and sleek look to it and incorporates tooltip based help to user for easy usage. Trade window mimic in game inventory to make it easy to use and intuative for any minecraft player allowing you to drag and drop items inside the window instead of clicking them once like most other trading scripts.

    Right click trading and command based trading (/trade <player>) are both supported by the system with optional checks such as seeing if the player is sneaking or ignored by the other player. Script also supports quick responding to trades by having clickable chat messages.

    Screenshots
    [​IMG]
    Example trading situation, our player is buying a diamond sword from the other player for 7 gold blocks, 8 gold ingots and 2 gold nuggets. Other player has accepted the trade shown by the yellow colored indicator.
    [​IMG]
    Showing the different chat messages and chat message interactability.
    [​IMG] [​IMG]
    Same trade from 2 points of view. Player in iron armour is trading a weapon with heavy use of custom NBT data.

    Dependencies and installation
    You need to have installed skript plugin to use this script. Download this script and place it in pre-generated folder at root\plugins\Skript\scripts.


    Add-ons needed to run the script with links:

    -Skellet
    -SkMirror

    Configuring
    There are editable properties and functions at the top of the script. Changing variable options is simply done by changing the value after the colon to any valid value and then reloading the script using /skript reload creepTrade command. Editable functions are bit more complicated and you should understand basics of skript before changing them [Tutorial on functions]. You can use most any expressions in functions that you could in other scripts but you need to change event-player to {_p} variable and event-item to {_i} variable. These functions need to always end in return true or return false. Script contains some commented out examples.

    Code (Text):
    1. options:
    2.     oRClick: true    #Right clicking a player initiates a trade
    3.     tradeTime: 10    #Time in seconds player has to accept trade
    4.     tradeDistance: 0 #Max distance between players, 0 = infinite
    5.     tradePermission: skript.user #Permission needed for /trade but not right click trade
    6.  
    7. function rightClick(p: player,other: player) :: boolean: #[
    8.     #
    9.     #  FEEL FREE TO ADD ADDITIONAL CHECKS HERE, ONLY APPLIES TO
    10.     #  RIGHT CLICK TRADE, EXAMPLES BELOW. RETURN FALSE FOR DENY
    11.     #  TRADE AND RETURN TRUE FOR ALLOWED TRADE
    12.     #if {_p} doesn't have permission "skript.rclicktrade":
    13.     #    return false
    14.     if {_p} is not sneaking:
    15.         return false
    16.     #if {_p}'s tool is not a stick:
    17.     #    return false
    18.     return true
    19. #]
    20.  
    21. function itemFilter(i: item, p: player) :: boolean:
    22.     #
    23.     #  FEEL FREE TO ADD ADDITIONAL CHECKS HERE. APPLIES WHEN
    24.     #  PLAYER PUTS ITEM INTO THE TRADE WINDOW, RETURN
    25.     #  FALSE IF YOU WANT TO PREVENT TRADING OF ITEMS
    26.     #if lore of {_i} contains "soulbound":
    27.     #    message "&cCan't trade soulbound items." to {_p}
    28.     #    return false
    29.     #if {_i} is tnt:
    30.     #    message "&cThat item is blacklisted." to {_p}
    31.     #    return false
    32.     return true

    Terms
    You can use and modify the script but not distribute it to others and you may not take credit for making it. Comments would be appreciated if you end up using it on your server.