Player Kill Stats Scoreboard
Author: mythanical
Created: 2013-10-20T06:01:12-0400
Edited: 2013-10-20T06:01:12-0400
Denizen Version: 0.9.3
Views: 18
Downloads: 908
Likes: 1
Description: Player Stats Scoreboards
====================
Citizens 2 (build #985)
Denizen 0.9.3 (build #1331)
DESCRIPTION:
============
This script contains two demonstrations:
1) The use of the "scoreboard" command in conjunction with some world events to flag players with kill & death statistics and show the stats ON SCREEN.
2) Use of the "sign" command to list the server leaders (top killers, PvP'ers etc) and the losers (most deaths, PvP deaths etc) at a specified location.
Screenshot: http://i.imgur.com/2JeqLwe.png
NOTE: There are a couple of extra flag commands that will create a player flag for every entity type that either kills the player or that the player kills. There is no use for it in the current version, but I intend on using those statistics in a future version and also create an OP command to clear all the stats and scoreboards.
Known issues: The "NPC Kills" doesn't work because the NPC seizes to exist before it can properly flag the values.
# Player Stats Scoreboards
# Citizens 2 (build #985)
# Denizen 0.9.3 (build #1331)
#
#
# DESCRIPTION:
# ============
#
# This script contains two demonstrations:
# 1) The use of the "scoreboard" command in conjunction with some
# world events to flag players with kill & death statistics.
#
# 2) Use of the "sign" command to list the server leaders (top killers, PvP'ers etc)
# and the losers (most deaths, PvP deaths etc) at a specified location.
#
# Screenshot: http://i.imgur.com/2JeqLwe.png
#
# You will have to update the sign locations further down so the signs go where
# you expect them to. NOTE: You have to give the coordinate of the EMPTY block right
# in front of the wall you want the sign to go against!!
#
# CREDITS:
# ========
# Thanks to davidcernat for implementing the scoreboard command!
#
# @author mythanical
# @script version 0.1
# @last-updated October 20 2013
# @irc EsperNet IRC Network #denizen-dev
# @Minecraft Server - minecraft.geek.nz
# @Donate Bitcoin: 1Fzacc2gZ5NGRMXg5jWP6NcUkWei34xjzt
# @Donate Litecoin: LhsaGa1QzmVLjMYwg4ZPTVnmSgnBDGc75U
"Sign Scoreboard Global Flags":
type: world
events:
on reload scripts:
# If the line below is set to "true", it will enable creating a wall of signs
# showing the current server leaders in PvP Kills, Mob Kills, Deaths, etc.
- flag global Sign_Scoreboard:true
#-------------------------------------------------------------------------------#
# Hall of Fame
# ============
# 1) Most Kills - This sign will show the player that has killed the most
# entities (player, NPC's or mobs).
# 2) PvP Kills - Player with the highest PvP score.
# 3) Mob Kills - Player that has killed the most mobs (aggressive and passive
# mobs, excluding NPC's).
# 4) NPC Kills - Player that has killed the most NPC's - THIS IS BROKEN - IT
# WILL NOT RETURN A RESULT.
# 5) A.I. Kills - Player that has killed the most NPC's and mobs.
# Hall of Shame
# =============
# 6) Most Deaths - The player who has died the most number of times.
# 7) Killed by PvP - Player that has died the most by PvP.
# 8) Killed by Mobs - Player that has been killed most by mobs.
# 9) Killed by NPC's - Player that has been killed most by NPC's
# 10) Killed by A.I. - Player that has been killed most by NPC's and mobs.
#
# Use: Specify a coordinate for the sign to appear in that spot, otherwise
# type "none" to prevent a sign from being placed.
#-------------------------------------------------------------------------------#
- if <global.flag[Sign_Scoreboard]> {
- flag global Sign_MostKills_Location:86,65,286,world
- flag global Sign_MostPVPKills_Location:86,66,287,world
- flag global Sign_MostMobKills_Location:86,64,287,world
- flag global Sign_MostNPCKills_Location:86,65,288,world
- flag global Sign_MostAIKills_Location:none
- flag global Sign_MostDeaths_Location:86,65,290,world
- flag global Sign_MostPVPDeaths_Location:86,66,291,world
- flag global Sign_MostMobDeaths_Location:86,64,291,world
- flag global Sign_MostNPCDeaths_Location:86,65,292,world
- flag global Sign_MostAIDeaths_Location:none
}
"Player Statistics Scoreboard":
type: world
events:
#-------------------------------------------------------------------------------#
# The 'on entity dies' event is used to flag the player who kills the entities
# with the relevant flags from each of the types below.
# There are primarily 3 different entity types:
# 1) Players
# 2) NPC's (Citizens NPC's)
# 3) Mobs (skeletons, zombies, cows, sheep etc)
#-------------------------------------------------------------------------------#
on entity dies:
- if <context.damager.is_player> {
- flag <context.damager> AllKills:++
- if <context.entity.is_player> flag <context.damager> PVPKills:++
else if <context.entity.is_npc> {
- flag <context.damager> NPCKills:++
- flag <context.damager> AIKills:++ }
else if <context.entity.is_mob> {
- flag <context.damager> MobKills:++
- flag <context.damager> AIKills:++
- flag <context.damager> Killed_<context.entity.entity_type>:++ }
- run "Scoreboard List" def:<context.damager>
- if <global.flag[Sign_Scoreboard]> run "Hall of Fame" def:<context.damager>
}
# The 'on player dies' event is used separate out the section to flag the player that got
# killed by any of the 3 entity types listed above.
# This section can actually happily go under the 'on entity dies'.
on player dies:
- flag <player> DeathCount:++
- if <context.damager.is_player> flag <player> PVPDeaths:++
else if <context.damager.is_npc> {
- flag <player> NPCDeaths:++
- flag <player> AIDeaths:++ }
else if <context.damager.is_mob> {
- flag <player> MobDeaths:++
- flag <player> AIDeaths:++
- flag <player> KilledBy_<context.damager.entity_type>:++ }
- run "Scoreboard List" def:<context.entity>
- if <global.flag[Sign_Scoreboard]> run "Hall of Shame" def:<context.entity>
"Scoreboard List":
type: task
script:
#-------------------------------------------------------------------------------#
# The %1% will be substituted by the player object. This got passed through by
# the 'run' command above that ran this task. That's what the
# "def:<context.entity>" was for.
#
# The first command below will be translated into something like this:
# - scoreboard viewers:p@mythanical id:mythanicStats obj:Stats lines:Deaths Score:1
#
# Reason why the "id" doesn't hold my full player name is because there is a 16
# char limit and using colour codes like <green> and <bold> use up some of that
# character limit. So the "substring[1,9]" is used to limit the length of the
# player name to 8 characters.
#
# Each player gets their own scoreboard objective called "Stats", the scoreboard
# id has part of their name in it and they are the only viewer of said
# scoreboard. It's possible to add lots of viewers, but in this instance
# wouldn't make a lot of sense.
#-------------------------------------------------------------------------------#
- ^scoreboard viewers:%1% id:<%1%.name.substring[1,9]>Stats "obj:<green><bold>Stats" "lines:<red>Deaths" score:<%1%.flag[DeathCount].asint||0>
- ^scoreboard viewers:%1% id:<%1%.name.substring[1,9]>Stats "obj:<green><bold>Stats" "lines:<dark_aqua>PvP Kills" score:<%1%.flag[PVPKills].asint||0>
- ^scoreboard viewers:%1% id:<%1%.name.substring[1,9]>Stats "obj:<green><bold>Stats" "lines:<dark_aqua>Other Kills" score:<%1%.flag[AIKills].asint||0>
- ^scoreboard viewers:%1% id:<%1%.name.substring[1,9]>Stats "obj:<green><bold>Stats" "lines:<gold>Money" score:<%1%.money.asint||0>
#-------------------------------------------------------------------------------#
# The following two scripts are used to create the signs in the locations
# set at the top.
#
# 1) Hall of Fame - Creates all the signs for the players that are leading
# for killing players (PvP), mobs and NPC's.
#
# 2) Hall of Shame - Same as above but signs for players that died the most.
#-------------------------------------------------------------------------------#
"Hall of Fame":
type: task
script:
#-------------------------------------------------------------------------------#
# The %1% means it'll substitute it for the '<context.damager>' from the
# 'on entity dies' event. That's why we used "def:<context.damager>" in the run
# command above.
#
# So, for the first one it checks to see if the killer player (damager) has a
# higher kill count score (AllKills) than what the global flag (MostKills) is.
# If it is, it's a new high score and it'll set a new value for the global flag
# called "MostKills" and then write the new sign on the wall.
#
# The "sign" command in this case specifies it should be a wall_sign, it then
# builds up the text on the sign (move onto the next line on the sign by using
# the '|' character) and places it at the location set in the corresponding
# global flag in the 'on reload scripts' event at the top.
#-------------------------------------------------------------------------------#
- if <%1%.flag[AllKills]||0> > <global.flag[MostKills]||0> && <global.flag[Sign_MostKills_Location]> != none {
- flag global MostKills:<%1%.flag[AllKills].asint>
- sign type:wall_sign "<bold>All Kills|<%1%.name>|Count<&co> <global.flag[MostKills].asint>" <global.flag[Sign_MostKills_Location]> }
- if <%1%.flag[PVPKills]||0> > <global.flag[MostPVPKills]||0> && <global.flag[Sign_MostPVPKills_Location]> != none {
- flag global MostPVPKills:<%1%.flag[PVPKills].asint>
- sign type:wall_sign "<bold>PVP Kills|<%1%.name>|Count<&co> <global.flag[MostPVPKills].asint>" <global.flag[Sign_MostPVPKills_Location]> }
- if <%1%.flag[MobKills]||0> > <global.flag[MostMobKills]||0> && <global.flag[Sign_MostMobKills_Location]> != none {
- flag global MostMobKills:<%1%.flag[MobKills].asint>
- sign type:wall_sign "<bold>Mob Kills|<%1%.name>|Count<&co> <global.flag[MostMobKills].asint>" <global.flag[Sign_MostMobKills_Location]> }
- if <%1%.flag[NPCKills]||0> > <global.flag[MostNPCKills]||0> && <global.flag[Sign_MostNPCKills_Location]> != none {
- flag global MostNPCKills:<%1%.flag[NPCKills].asint>
- sign type:wall_sign "<bold>NPC Kills|<%1%.name>|Count<&co> <global.flag[MostNPCKills].asint>" <global.flag[Sign_MostNPCKills_Location]> }
- if <%1%.flag[AIKills]||0> > <global.flag[MostAIKills]||0> && <global.flag[Sign_MostAIKills_Location]> != none {
- flag global MostAIKills:<%1%.flag[AIKills].asint>
- sign type:wall_sign "<bold>AI Kills|<%1%.name>|Count<&co> <global.flag[MostAIKills].asint>" <global.flag[Sign_MostAIKills_Location]> }
"Hall of Shame":
type: task
script:
- if <%1%.flag[DeathCount]||0> > <global.flag[MostDeathsCount]||0> && <global.flag[Sign_MostDeaths_Location]> != none {
- flag global MostDeathsCount:<%1%.flag[DeathCount].asint>
- sign type:wall_sign "<bold>Most Deaths|<%1%.name>|Count<&co> <global.flag[MostDeathsCount].asint>" <global.flag[Sign_MostDeaths_Location]> }
- if <%1%.flag[PVPDeaths]||0> > <global.flag[MostPVPDeaths]||0> && <global.flag[Sign_MostPVPDeaths_Location]> != none {
- flag global MostPVPDeaths:<%1%.flag[PVPDeaths].asint>
- sign type:wall_sign "<bold>PVP Deaths|<%1%.name>|Count<&co> <global.flag[MostPVPDeaths].asint>" <global.flag[Sign_MostPVPDeaths_Location]> }
- if <%1%.flag[MobDeaths]||0> > <global.flag[MostMobDeaths]||0> && <global.flag[Sign_MostMobDeaths_Location]> != none {
- flag global MostMobDeaths:<%1%.flag[MobDeaths].asint>
- sign type:wall_sign "<bold>Mob Deaths|<%1%.name>|Count<&co> <global.flag[MostMobDeaths].asint>" <global.flag[Sign_MostMobDeaths_Location]> }
- if <%1%.flag[NPCDeaths]||0> > <global.flag[MostNPCDeaths]||0> && <global.flag[Sign_MostNPCDeaths_Location]> != none {
- flag global MostNPCDeaths:<%1%.flag[NPCDeaths].asint>
- sign type:wall_sign "<bold>NPC Deaths|<%1%.name>|Count<&co> <global.flag[MostNPCDeaths].asint>" <global.flag[Sign_MostNPCDeaths_Location]> }
- if <%1%.flag[AIDeaths]||0> > <global.flag[MostAIDeaths]||0> && <global.flag[Sign_MostAIDeaths_Location]> != none {
- flag global MostAIDeaths:<%1%.flag[AIDeaths].asint>
- sign type:wall_sign "<bold>AI Deaths|<%1%.name>|Count<&co> <global.flag[MostAIDeaths].asint>" <global.flag[Sign_MostAIDeaths_Location]> }