Paste #121145: Auction

Date: 2024/03/19 02:05:41 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


ah_command:
    type: command
    name: ah
    debug: false
    description: Buy and Sell player items!
    usage: /ah sell (price)
    tab completions:
        1: sell
    script:
    - if <context.args.size> > 0:
        - choose <context.args.get[1]>:
            - case sell:
                - define item <player.item_in_hand>
                - define quantity <[item].quantity>
                - if <[item]> == <item[air]>:
                    - narrate "Please hold an item to sell"
                    - stop
                - define lore <[item].lore.if_null[]>
                - define item <[item].with_flag[auction_item].with_flag[seller:<player>]>
                - define item <[item].with_flag[price:<[price]>]>
                - define rank <player.luckperms_primary_group.group_name>
                - if <[rank]> == default:
                    - define duration 6h
                - else if <[rank]> == syfon:
                    - define duration 18h
                - else:
                    - define duration 24h
                    #Should I add a tax system? :thinking:
                - define item <[item].with_flag[expire_after].duration[<[duration]>]>
                - define seller <[item].flag[seller]>
                - define price <[item].flag[price]>
                - define time <[item].flag_expiration[expire_after].from_now.formatted>
                - define info "<&nl><&a>Price: <&e><&l><[price]><&nl><&a>Seller: <&e><&l><[seller].name><&nl><&a>Time Left: <&e><&l><[time]>"
                - adjust def:item "lore:<[lore]> <[info]>"
                - flag server ah.items:->:<[item]>
                - take iteminhand quantity:<[quantity]>

ah_handler:
    type: world
    debug: false
    events:
        on player clicks item_flagged:auction_item in auction_player_lists:
            - define item <context.item>
            - define time <[item].flag_expiration[expire_after]>
            - narrate <[time].format[dd/MM/yyyy : HH:mm:SS]>