Paste #1485: John Hancock v2

Date: 2014/01/26 22:27:03 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


SignClickGetTitleEvents:
  type: world
  events:

    on player changes sign:
    - if <player.is_op> && <context.new.get[1]> == "[Title]" {
      - if <context.new.get[2]> == "" narrate "Line 2 must be the title the player will be receive!"
        else if <context.new.get[4]> != "" && <context.new.get[4].as_int> == null narrate "Line 4 must be a valid number!"
        else {
        - if !<global.flag[TitleSigns].contains[<context.location>]> flag global "TitleSigns:->:<context.location>"
        - define type "<context.material.bukkit_enum>"
        - define line1 "<&lb><&b>Title<&r><&rb>"
        - define line2 "<context.new.get[2]>"
        - define line4 "<context.new.get[4].as_int||200>"
        - define location "<context.location>"
        - inject s@DelayedSignClickGetTitleTask
        }
      }

    on player right clicks wall_sign:
    - if <global.flag[TitleSigns].contains[<context.location>]>
      run s@SignClickGetTitleTask "def:li@<context.location.sign_contents.get[2]>|<context.location.sign_contents.get[4].substring[2]>"
    on player right clicks sign_post:
    - if <global.flag[TitleSigns].contains[<context.location>]>
      run s@SignClickGetTitleTask "def:li@<context.location.sign_contents.get[2]>|<context.location.sign_contents.get[4].substring[2]>"

DelayedSignClickGetTitleTask:
  type: task
  script:
  - sign type:%type% "li@%line1%|%line2%||$%line4%" %location%

SignClickGetTitleTask:
  type: task
  definitions: title|cost
  script:
  - if <player.money||0> < %cost% narrate "You don't have enough money for that title!"
    else {
    - execute as_server "manuaddv <player.name> suffix %title%"
    - take money qty:%cost%
    - narrate "Congratulations! You now have the title<&co> %title%"
    }