Revised little trading script

  • 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 community!

    Now, what are you waiting for? Join the community now!

Juc70

New Member
Jun 7, 2017
8
1
3
gzaqXop.png

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
GzA8C27.png

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.
lP8m9HB.png

Showing the different chat messages and chat message interactability.
Ym4KGp5.png
C71i3AZ.png

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:
options:
    oRClick: true    #Right clicking a player initiates a trade
    tradeTime: 10    #Time in seconds player has to accept trade
    tradeDistance: 0 #Max distance between players, 0 = infinite
    tradePermission: skript.user #Permission needed for /trade but not right click trade

function rightClick(p: player,other: player) :: boolean: #[
    #
    #  FEEL FREE TO ADD ADDITIONAL CHECKS HERE, ONLY APPLIES TO
    #  RIGHT CLICK TRADE, EXAMPLES BELOW. RETURN FALSE FOR DENY
    #  TRADE AND RETURN TRUE FOR ALLOWED TRADE
    #if {_p} doesn't have permission "skript.rclicktrade":
    #    return false
    if {_p} is not sneaking:
        return false
    #if {_p}'s tool is not a stick:
    #    return false
    return true
#]

function itemFilter(i: item, p: player) :: boolean:
    #
    #  FEEL FREE TO ADD ADDITIONAL CHECKS HERE. APPLIES WHEN
    #  PLAYER PUTS ITEM INTO THE TRADE WINDOW, RETURN
    #  FALSE IF YOU WANT TO PREVENT TRADING OF ITEMS
    #if lore of {_i} contains "soulbound":
    #    message "&cCan't trade soulbound items." to {_p}
    #    return false
    #if {_i} is tnt:
    #    message "&cThat item is blacklisted." to {_p}
    #    return false
    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.