-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeathboard.sc
83 lines (63 loc) · 1.73 KB
/
deathboard.sc
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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
__config() -> {
'scope' -> 'global',
'commands' -> {
'' -> _() -> print(deathboard(false));
}
};
get_deaths() -> (
deaths = read_file('deaths', 'json') || {};
return (deaths);
);
// probably a bit overkill to check for every player
// probably...
update_deaths() -> (
schedule(0, _() -> (
task(_() -> (
deaths = get_deaths();
for (player('*'), (
p = str(_);
deaths:p = statistic(p, 'custom', 'deaths');
));
write_file('deaths', 'json', deaths);
));
));
);
deathboard(to_discord) -> (
deaths = get_deaths();
list = [if (to_discord, (
'**\\💀 the deathboard leaderboard board \\💀**',
'§6=== ☠ §lthe deathboard leaderboard board§r §6☠ ===';
))];
for (sort_key(pairs(deaths), -_:1), (
p = _:0;
deaths = _:1;
if (deaths == 0, continue());
list += if (to_discord, (
str('**%s** \\💀 %s', deaths, p),
str('§6%s ☠ %s', deaths, p);
));
));
if (length(list) == 1, list += 'no tracked deaths yet');
return (join('\n', list));
);
__on_start(p) -> update_deaths();
__on_player_connects(p) -> update_deaths();
__on_player_dies(p) -> update_deaths();
// dcmc support
dcmc_cmds = system_variable_get('dcmc_cmds', {});
dcmc_cmds:'deathboard' = {};
dcmc_cmds:'deathboard':'category' = 'deathboard';
dcmc_cmds:'deathboard':'help' = [
'show the deathboard leaderboard board'
];
dcmc_cmds:'deathboard':'callback' = 'dcmc_deathboard';
dcmc_cmds:'board' = {};
dcmc_cmds:'board':'category' = 'deathboard';
dcmc_cmds:'board':'help' = [
'alias for the deathboard leaderboard board but assed'
];
dcmc_cmds:'board':'callback' = 'dcmc_deathboard';
handle_event('dcmc_deathboard', _(_) -> (
signal_event('return_dcmc_deathboard', null, deathboard(true));
));
system_variable_set('dcmc_cmds', dcmc_cmds);