- D1 Meta Docs - Denizen Script -
Home Page / Pi to one million places / Contact mcmonkey / Donate / Paste Scripts / Denizen Help /
You are browsing as a guest.
Login | Register


Click here to create your own public paste ~ ~ click to duplicate and edit this paste


TitleRepo Script Leaderboards
TypeDenizen Script
Date2016/01/16 17:54:57 UTC-08:00
ByFortifier42
Other
Paste
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
6900
LeaderBoard_Version:
  type: version
  name: LeaderBoard
  id: 71
  description: A PVP Leaderboard system.
  version: 1.0

LeaderBoard_Command:
  type: command
  name: leaderboard
  aliases:
  - leaders
  - leader
  - leaderboards
  usage: /leaderboard
  description: Check the pvp leaderboards!
  script:
    - narrate "----- <&6>Leaderboards<&r> -----"
    - if <server.has_flag[leaders].not> {
      - narrate "Sorry, there are <&6>no<&r> leaders at this time!"
      - queue clear
    }
    - foreach <server.flag[leaders].as_list> {
      - narrate "<def[loop_index]><&6><def[Value].name><&r> - KDR<&6><def[value].flag[kill_death_ratio]||0><&r> (<&6><def[value].flag[kill_score]||0> <&r>Kills & <&6><def[Value].flag[death_score]||0><&r> Deaths)"
    }

LeaderBoard_Handler:
  debug: false
  type: world

  ## A death!
  death:
  - flag <player> "death_score:++"
  - flag <player> "kill_death_ratio:<player.flag[kill_score].div[<player.flag[death_score]>].round_to[2]||0>"

  ## A kill!
  kill:
  - flag <player> "kill_score:++"
  - flag <player> "kill_death_ratio:<player.flag[kill_score].div[<player.flag[death_score]||1>].round_to[2]>"

  events:
    ## Someone got smacked in the face! :o
    on player kills player:
    - run <script> path:kill player:<context.damager> instantly
    - run <script> path:death player:<context.entity> instantly
    - flag server "leaders:!"
    - define Leaders <server.list_players.filter[has_flag[kill_death_ratio]].sort[LeaderBoard_Sort].get[1].to[5]||li@>
    - if <def[Leaders].is_empty.not> {
      - flag server "leaders:|:<def[Leaders]>"
    }

LeaderBoard_Sort:
  type: procedure
  debug: false
  definitions: p1|p2
  script:
  ## If P2's kill score is better than P1's move P2 up, ooh that bitch is climbin!
  - if <def[p2].flag[kill_death_ratio]||0> > <def[p1].flag[kill_death_ratio]||0> {
    - determine 1
  }
  ## If P1's kill score is better than P2's move P1 up, ooh that bitch is climbin!
  else if <def[p1].flag[kill_death_ratio]||0> > <def[p2].flag[kill_death_ratio]||0> {
    - determine -1
  }
  ## Their kill score is equal, so do nothing... boring..
  else {
    - determine 0
  }



RawRaw



Pastes made: 72179