Leaderboard:
type: world
events:
on player killed by player:
#Check if flag exists, if not, make the base list
- flag <context.damager.as_player> kill_player_count:++
- flag <context.entity.as_player> death_player_count:++
#Check top 5 values to see if player exceeded them
- define x 1
- define KD <context.damager.as_player.flag[kill_player_count].div[<context.damager.as_player.flag[death_player_count]>]||0>
- while <def[x].is[OR_LESS].than[5]>{
- define TopPlayer <server.flag[Leaderboard_<def[x]>]||"NA">
- - define TopKD <<def[TopPlayer]>.flag[kill_player_count].div[<<def[TopPlayer]>.flag[death_player_count]>]||0>>
+ - define TopKD <<def[TopPlayer]>.flag[kill_player_count].div[<<def[TopPlayer]>.flag[death_player_count]>]||0>
- if <def[KD].is[OR_GREATER].than[<def[TopKD]>]> {
- define y 5
#For every value under the player, copy the flag to the next position
- - while <def[y].is[GREATER].than[<def[x]>] {
+ - while <def[y].is[GREATER].than[<def[x]>]> {
#Copy the flag
- flag server Leaderboard_<def[y]>:<server.flag[Leaderboard_<def[y].sub_int[1]>]>
}
#Break the loop
- define x 6
#Add the new player to the list
- flag server Leaderboard_<def[x]>:<context.damager.as_player>
- - define x <def[x].add[1]>
- }
+ - define x <def[x].add[1]>
+ }
- determine fulfilled
on leaderboard command:
- narrate "1. <server.flag[Leaderboard_1]||'NA'> 2. <server.flag[Leaderboard_2]||'NA'> 3. <server.flag[Leaderboard_3]||'NA'> 4.<server.flag[Leaderboard_4]||'NA'> 5. <server.flag[Leaderboard_5]||'NA'>"
on stats command:
- narrate "<player.flag[kill_player_count].div[<player.flag[death_player_count]>]||0>"