Paste #39772: Donate

Date: 2017/02/08 21:02:47 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


Donatecommand:
  type: command
  name: donate
  usage: /donate <player> <amount>
  description: Donates XP to another player.
  permission: xpcraft.donate
  permission message: <&c>Sorry, this command is premium only. Purchase a rank in the store to gain access!
  script:
  - if <context.args.size.is[EQUALS].than[0]> {
    - narrate "<&a>You<&sq>ve donated XP to other players <&b><player.flag[donated].as_int> <&a>times!"
    - queue clear
    }
  - if <context.args.size.is[EQUALS].than[1]> || !<context.args.get[2].is[matches].to[number]> {
    - narrate "<&c>Usage: /donate <&lt>player<&gt> <&lt>amount<&gt>"
    - queue clear
    }
  - if <player.flag[xp].as_int.is[LESS].than[<context.args.get[2].as_int>]> {
    - narrate "<&c>You don<&sq>t have enough XP!"
    - queue clear
    }
  - if <context.args.get[1].contains_text[<player.name>]> {
    - narrate "<&c>(`-ะด-) ....seriously?"
    - queue clear
    }
  - if <player.has_flag[donationcooldown]> {
    - narrate "<&c>You have already donated XP today. You will be able to use this command again in <player.flag[donationcooldown].expiration.formatted>."
    - queue clear
    }
  - define arg1 <server.match_offline_player[<context.args.get[1]>]||null>
  - if <def[arg1]> == null {
    - narrate "<&c>Usage: /donate <&lt>player<&gt> <&lt>amount<&gt>"
    - queue clear
    }
  - define donationtimes <player.flag[donated].as_int>
  - define minimum <el@def[donationtimes].as_int.power[<def[donationtimes].as_int>].power[0.015].round_down>
  - if <context.args.get[2].as_int.is[LESS].than[<def[minimum]>]> {
    - narrate "<&c>The current minimum XP you can donate is <&b><def[minimum]><&c>!"
    - queue clear
    } else {
    - flag <def[arg1]> xp:+:<context.args.get[2].as_int>
    - flag <player> xp:-:<context.args.get[2].as_int>
    - flag <player> donated:+:1
    - flag <player> donationcooldown duration:24h
    - narrate "<&a>Donated <&B><context.args.get[2]> <&A>XP to <context.args.get[1]>!" target:<player>
    - if <def[arg1].is_online> {
      - narrate "<&a><player.name> has donated <&b><context.args.get[2].as_int> <&a>XP to you!" target:<def[arg1]>
      }
#    - run Achievements instantly
    }