Skip to content

Commit c85c508

Browse files
committed
Add scoreboard example
1 parent 2ff51b9 commit c85c508

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

src/components/examples.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,5 +77,22 @@ const examples = [
7777
`,
7878
dataSet: playerData
7979
},
80+
{
81+
name: 'Scoreboard of top players',
82+
description: 'Shows a top 5 of online players sorted by their zombie kills',
83+
input: `
84+
say "Top 5 players online by Kills:";
85+
{{!-- Sort the array of online players --}}
86+
{{#each (sort server.onlinePlayers "zombieKills" "desc")}}
87+
{{!-- @index is how many iterations we have done, so for a top 5 we only print when @index is smaller than 5 --}}
88+
{{#if (lt @index 5)}}
89+
say "{{this.name}} {{this.zombieKills}} Kills, {{this.deaths}} Deaths";
90+
say "KLR = {{round ( divide this.zombieKills (sum this.deaths 1)) 1}}";
91+
{{/if}}
92+
{{/each}}
93+
`,
94+
dataSet: playerData
95+
},
8096
]
8197

98+

0 commit comments

Comments
 (0)