zourfr

Can you make me a Skript /lend:

Normally, without any argument, it will open a menu, which is like an auction house. Where player can list item they wanna lend, with the price per hour, the item.

On the bottom row is search, next page, last page, your item, sorting and refresh.

/lend list <price>

It will then open a confirmation menu, confirming the player if they want to let other lend the item they are holding for <price> per hour or not.

/lend view <user> it will view all of item the <user> has let for lend

/lend lock / unlock (OP)

Unlock / Lock Lending Feature

Kodari AI
KodariJun 25 at 4:06 pm 99
LendShop
A full item lending marketplace for Minecraft servers. Players browse a paginated GUI showing all listed items with price-per-hour, lend their own items via a confirmation menu, and borrow items by choosing a duration. Features search by name (chat input), three sort modes, per-player listing views, unlist support, Vault economy integration, borrow expiry scheduling, and an OP lock/unlock toggle.

LendShop.sk — Setup Guide

Install: Drop LendShop.sk into plugins/Skript/scripts/ then run /sk reload LendShop.

Requirements:

  • Skript 2.6+

  • Vault + any economy plugin (EssentialsX, CMI, etc.) — required for borrowing/payments


Commands

Command
Description
/lend
Open the marketplace browser
/lend list <price>
List held item at
<price>
per hour
/lend view <player>
View all of a player’s listings
/lend lock
(OP)
Disable the feature globally
/lend unlock
(OP)
Re-enable it

Feature Overview

Browse GUI (6 rows)

  • Slots 0–44 show all active listings with owner, price/hr, and original item lore preserved

  • Bottom row: 🔍 Search → chat input (type cancel to clear) | ↕ Sort (cycles Newest → Price ↑ → Price ↓) | ◀ Prev | 🕐 Refresh + page counter | ▶ Next | 📦 Your Listings | ✖ Close

Confirm Listing GUI — Shows item preview + price, takes item from main hand on confirm

View GUI — Shows both active and borrowed listings; clicking your own active listing unlists it; clicking someone else’s listing lets you borrow it

Borrow Hours GUI — Five duration buttons (1h / 2h / 4h / 8h / 24h) with color gradient (green→red), shows total cost per option

Expiry system — Borrow duration tracked with a scheduled wait; if the server restarts, /script load re-checks all expired borrows automatically

zourfr

its bugged

Kodari can make mistakes. Review important code before using.
Files
LendShop.sk
Code
1 881
LendShop.sk
# ═══════════════════════════════════════════════════════════════════
# LendShop.sk — Item Lending Marketplace
# ───────────────────────────────────────────────────────────────────
#
# Commands:
#   /lend              — Open the lending marketplace browser
#   /lend list <$/hr>  — List the item in your main hand for rent
#   /lend view <user>  — View all of a player's active/borrowed listings
#   /lend lock         — (OP) Disable lending for all non-OP players
#   /lend unlock       — (OP) Re-enable lending
#
# Requirements:
#   Skript 2.6+  |  Vault + any Economy plugin (EssentialsX, CMI…)
#
# Install : plugins/Skript/scripts/LendShop.sk
# Reload  : /sk reload LendShop
#
# ── Variable Reference ────────────────────────────────────────────
#
#  {lend::locked}                        — boolean, global lock
#  {lend::nextid}                        — auto-increment counter
#  {lend::listings::*}                   — list of all listing IDs
#  {lend::listing::%id%::item}           — stored ItemStack
#  {lend::listing::%id%::owner}          — owner display name
#  {lend::listing::%id%::price}          — price/hr (number)
#  {lend::listing::%id%::active}         — true = available to borrow
#  {lend::listing::%id%::borrower}       — borrower display name
#  {lend::listing::%id%::borrow_until}   — unix expiry timestamp
#  {lend::listing::%id%::timestamp}      — unix creation timestamp
#
#  Per-player state (cleaned up on inventory close):
#  {lend::gui::%p%}        — current GUI tag
#  {lend::page::%p%}       — browse page number
#  {lend::sort::%p%}       — sort mode (newest/price_asc/price_desc)
#  {lend::search::%p%}     — active search filter
#  {lend::searching::%p%}  — true while awaiting chat input
#  {lend::viewtarget::%p%} — player name for view GUI
#  {lend::viewpage::%p%}   — page number for view GUI
#  {lend::borrowid::%p%}   — listing ID staged for borrow
#  {lend::opening::%p%}    — transition flag (prevents stale cleanup)
#  {lend::slot::%p%::%n%}  — maps GUI slot → listing ID
#
#  Pending listing (set by /lend list, consumed by confirm GUI):
#  {lend::pending::%p%::item}
#  {lend::pending::%p%::price}
# ═══════════════════════════════════════════════════════════════════

options:
    prefix: &8[&6Lend&8]&r


# ─────────────────────────────────────────────────────────────────
#  INITIALIZATION
# ─────────────────────────────────────────────────────────────────

on script load:
    if {lend::nextid} is not set:
        set {lend::nextid} to 0
    if {lend::locked} is not set:
        set {lend::locked} to false
    # Restore any listings whose borrow period expired during downtime
    loop {lend::listings::*}:
        set {_id} to loop-value
        if {lend::listing::%{_id}%::active} is false:
            if {lend::listing::%{_id}%::borrow_until} is set:
                if unix timestamp of now >= {lend::listing::%{_id}%::borrow_until}:
                    set {lend::listing::%{_id}%::active} to true
                    delete {lend::listing::%{_id}%::borrower}
                    delete {lend::listing::%{_id}%::borrow_until}
    send "&8[&6Lend&8] &aLendShop loaded." to console

on script unload:
    loop all players:
        delete {lend::gui::%loop-player%}
        delete {lend::opening::%loop-player%}


# ─────────────────────────────────────────────────────────────────
#  CHAT — Search query capture
# ─────────────────────────────────────────────────────────────────

on chat:
    if {lend::searching::%player%} is true:
        cancel event
        if message is "cancel":
            delete {lend::search::%player%}
            send "{@prefix} &7Search filter cleared." to player
        else:
            set {lend::search::%player%} to message
            send "{@prefix} &7Searching for: &f%message%" to player
        delete {lend::searching::%player%}
        set {lend::page::%player%} to 1
        wait 1 tick
        lend_openBrowse(player)


# ─────────────────────────────────────────────────────────────────
#  INVENTORY — Close cleanup
# ─────────────────────────────────────────────────────────────────

on inventory close:
    if {lend::opening::%player%} is not set:
        if {lend::gui::%player%} is set:
            delete {lend::gui::%player%}
            loop 45 times:
                delete {lend::slot::%player%::%loop-number - 1%}


# ─────────────────────────────────────────────────────────────────
#  INVENTORY — Click dispatcher
# ─────────────────────────────────────────────────────────────────

on inventory click:
    if {lend::gui::%player%} is set:
        cancel event
        set {_raw} to rawslot of event-slot
        set {_gui} to {lend::gui::%player%}
        if {_gui} is "browse":
            lend_browseClick(player, {_raw})
        else if {_gui} is "confirm":
            lend_confirmClick(player, {_raw})
        else if {_gui} is "view":
            lend_viewClick(player, {_raw})
        else if {_gui} is "hours":
            lend_hoursClick(player, {_raw})


# ─────────────────────────────────────────────────────────────────
#  COMMAND: /lend
# ─────────────────────────────────────────────────────────────────

command /lend [<text>] [<text>]:
    trigger:
        set {_a1} to arg-1 ? "open"
        set {_a2} to arg-2 ? ""

        # ── OP lock / unlock ──────────────────────────────────────
        if {_a1} is "lock" or {_a1} is "unlock":
            if player is not op:
                send "{@prefix} &cYou must be OP to use this command." to player
                stop
            if {_a1} is "lock":
                set {lend::locked} to true
                send "{@prefix} &cLending has been &4locked&c." to player
            else:
                set {lend::locked} to false
                send "{@prefix} &aLending has been &2unlocked&a." to player
            stop

        # ── Global lock gate ──────────────────────────────────────
        if {lend::locked} is true:
            if player is not op:
                send "{@prefix} &cLending is currently disabled by an admin." to player
                stop

        # ── /lend list <price> ────────────────────────────────────
        if {_a1} is "list":
            if {_a2} is "":
                send "{@prefix} &cUsage: &f/lend list <price per hour>" to player
                stop
            if player's tool is air:
                send "{@prefix} &cYou must hold an item in your main hand to list it." to player
                stop
            set {_price} to {_a2} parsed as number
            if {_price} is not set:
                send "{@prefix} &c'%{_a2}%' is not a valid number." to player
                stop
            if {_price} <= 0:
                send "{@prefix} &cPrice per hour must be greater than 0." to player
                stop
            set {lend::pending::%player%::item}  to player's tool
            set {lend::pending::%player%::price} to {_price}
            lend_openConfirm(player)
            stop

        # ── /lend view <player> ───────────────────────────────────
        if {_a1} is "view":
            if {_a2} is "":
                send "{@prefix} &cUsage: &f/lend view <player>" to player
                stop
            set {lend::viewtarget::%player%} to {_a2}
            set {lend::viewpage::%player%}   to 1
            lend_openView(player)
            stop

        # ── Default — open browse ─────────────────────────────────
        if {lend::page::%player%} is not set:
            set {lend::page::%player%} to 1
        if {lend::sort::%player%} is not set:
            set {lend::sort::%player%} to "newest"
        lend_openBrowse(player)


# ═══════════════════════════════════════════════════════════════════
#  DATA FUNCTIONS
# ═══════════════════════════════════════════════════════════════════

# ── Return filtered + sorted active listing IDs ──────────────────

function lend_getListings(sort: text, search: text, owner: text) :: texts: