Paste #44338: Edit of P#44337 - Edit of P#44336 - Edit of P#44335 - Edit of P#44334 - Edit of P#44333 - Edit of P#

Date: 2017/09/11 03:42:26 UTC-07:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


#
# author: Zughy featured in: mc.trickerytown.com
#
# HOW DOES IT WORK
# This script allows you to implement a "give to player" objective in BetonQuest. You just need to right click any player in the server!
#
# WHAT YOU NEED
# 1 - create a folder inside the BetonQuest's and rename it "ADDON"
# 2 - in that folder create a package named Denizen (BEWARE: you can rename these 2 folders as you like, just remember to change also the code below)
# 3 - to start the objective, you must run the command I put in the last few lines of code. I usually run it via another event where I give the items the player needs to distribute.
#     So yeah, this WON'T give the quest item, you have to add a "^give <something>" inside the event
# 4 - the item you want to distribute must have a "#<number>" in the last line of the lore
# 5 - inside the "Denizen" package, you must create an event called "<number>TALK", which will be triggered when the player gives away all the quest items
#

talk_event_handler:
    type: world
    events:
        on player right clicks at player:
        - if !<player.list_flags.filter[starts_with[talk]].is_empty> && "<context.item.lore.last.contains_text[Deliver #]>" {
            - run talk_event def:<player>|<context.entity.name>|<context.item.lore.last> instantly
            }
talk_event:
    type: task
    definitions: pl|clicked_pl|lore
    script:
    # if the last line doesn't contain any colour, change substring[12] with substring[8] 
    # else if it contains a colour AND a format like italic, bold etc., change substring[12] with substring[16]
    - define qID '<def[lore].substring[12]>'
    #
    # if the clicked player is new
    #
    - if - if <def[pl].has_flag[talk<def[qID>]>]> && !<def[pl].flag[talk<def[qID]>].as_list.contains[<def[clicked_pl]>]> {
        - flag <def[pl]> talk<def[qID]>:->:<def[clicked_pl]>
        - flag <def[pl]> talk<def[qID]>[1]:-:1
        - take iteminhand quantity:1
        - give <def[pl].item_in_hand> quantity:1 player:<def[clicked_pl]>
        - narrate "<&a>Received <def[pl].item_in_hand.name> from <def[pl]>" targets:<def[clicked_pl]>
        #
        # if it was the last player to click on, trigger the event
        #
        - if <player.flag[talk<def[qID]>].get[1]> == 0 {
            - narrate "<&a>Completed!" targets:<def[pl]>
            # in case you want to rename the 2 folders and/or change the path, just edit here
            - execute as_server "q e <def[pl].name> ADDON-Denizen.<def[qID]>TALK"
            - flag <def[pl]> talk<def[qID]>:!
            #
            # or tell the player how many are left
            #
            } else {
            - narrate "<&a>Item delivered! <player.flag[talk<def[qID]>].get[1].round_down> players left" targets:<def[pl]>
            }
        #
        # if they've clicked that player already
        #
        } else {
        - narrate "<&c>You've already given the item to this player" targets:<def[pl]>
        }
talk_command:
    type: command
    name: dtalk
    permission: denizen.bypass
    script:
    #
    # /dtalk <player> <quest_n°> <players needed>
    # i.e: "/dtalk Zughy 15 5" will start the objective for Zughy, requiring an item having "#15" in the description and 5 players to deliver that item
    #
    - flag <context.args.get[1].as_player> talk<context.args.get[2]>:<context.args.get[3]>