Date: 2017/02/08 21:02:47 UTC-08:00
Type: Denizen Script
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
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 <<>player<>> <<>amount<>>"
- 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 <<>player<>> <<>amount<>>"
- 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
}