Tutorial by: J__00


UPDATED!!

Hello! If you're reading this tutorial then you probably need help making a scoreboard, if so don't worry, I'll teach you step by step how to make a clean Scoreboard without flickering.

REQUIREMENTS:
Skript
SkBee

Additional:
Vault and an Economy plugin (ex. Essentials)

Notes:

First we need an event:

on join:

with this event the scoreboard will be set to the player every time they join, but that won't happen by itself, we need to add a while loop, a while loop is a section that will run the code indented in it continuously as long as the condition used is met.

(Side Note: A common mistake when using the On Join event is to save the file, reload it and expect it to change, to see the applied changed you'll need to disconnect and join back and yes, this means that if you have players on they'll need to rejoin which is a good reason to apply changes when nobody is on.)

When using scoreboard you'll need to set the title and lines (A scoreboard requires a title, it won't show up otherwise)

on join:
  set title of player's scoreboard to "&eMy Server"
  set line 1 of player's scoreboard to "&7Server Ip: mc.myserver.net"

A an example let's add a few more lines

on join:
  set title of player's scoreboard to "&eMy Server"
  set line 4 of player's scoreboard to "&a" #blank line
  set line 3 of player's scoreboard to "&fPlayer: %player%"
  set line 2 of player's scoreboard to "&fKills: %{kills::%player's uuid%}%"
  set line 1 of player's scoreboard to "&7Server Ip: mc.myserver.net"

As you may have noticed the second line (the one with the kills list) will only be set ONCE in this event and won't be set afterwards, no worries we'll get to that later!

Now, it's important to note (especially for newbies) that here we're using expressions and lists inside of the lines, in the 3rd line we're using the player expression which returns the name of the player, pretty simple, in the 2nd line we are using a variable list for the kills. (Note: to use expressions, variables or functions in a string to return their values you will need to surround them with %, ex: "%player%", "%tps%" [tps is a paper only expression])

"but why a list?"

"why use the uuid"

By having a list used this way with the uuid of the player we (and skript) can manage it better!
For starters the name of the player can be changed by the player and so you should NEVER use variables with the player expression, the uuid expression on the other hand will never change, it will always stay the same for every account.

As a quick example, if I were to decide i didn't want to make a pvp server anymore and wanted to switch to a creative server, these lists would not be needed anymore and so instead of deleting each one (like you're forced to do if you use dots in variables) all you need to do is delete {kills::*}, done. (There are ways do delete a whole variable "dot" list by looping all the players but that's still a red flag compared to how easy it is to get rid of an actual list.)

"but why does it display <none>?"

When we added the kills list variable we didn't add a way to actually tell the server that the default value is 0, no worries though, if we were to add 1 to it skript would understand we're working with numbers and turn it from <none> to 1.

To actually answer the question we'll use the 'otherwise' expression, this expressions replaces a value with another one of choice if the first one is not set.

(In this case i will use the "?" alias but keep in mind that "?" and "otherwise" work just the same.)

on join:
  set title of player's scoreboard to "&eMy Server"
  set line 4 of player's scoreboard to "&a"
  set line 3 of player's scoreboard to "&fPlayer: %player%"
  set line 2 of player's scoreboard to "&fKills: %{kills::%player's uuid%} ? 0%"  #here we're using the otherwise expression
  set line 1 of player's scoreboard to "&7Server Ip: mc.myserver.net"

Now let's add deaths too!

on join:
  set title of player's scoreboard to "&eMy Server"
  set line 5 of player's scoreboard to "&a"
  set line 4 of player's scoreboard to "&fPlayer: %player%"
  set line 3 of player's scoreboard to "&fKills: &c%{kills::%player's uuid%} ? 0%"
  set line 2 of player's scoreboard to "&fDeaths: &c%{deaths::%player's uuid%} ? 0%"
  set line 1 of player's scoreboard to "&7Server Ip: mc.myserver.net"

Just like that, it will display the kills and deaths count.

But how do these numbers go up? Well, by using some logic.

Earlier in the tutorial i've mentioned that the lines with values will be set ONCE thanks to the join event, but for these numbers to actually go up we'll need the proper events that make those values change.

In this case Skript handles doesn't handle "kills" it handles "deaths", in fact we'll use the death event and manipulate the kills and deaths lists along with the lines in which they are used in in this event!

Keep in mind this event does NOT have the player event value, just like the damage event this one has the victim and attacker event values.

on death of player:
  if attacker is a player:
    add 1 to {kills::%attacker's uuid%}
    set line 3 of attacker's scoreboard to "&fKills: &c%{kills::%attacker's uuid%} ? 0%"
  add 1 to {deaths::%victim's uuid%}
  set line 2 of victim's scoreboard to "&fDeaths: &c%{deaths::%victim's uuid%} ? 0%"

You may notice i've added a condition at the beginning, this is because (normally) players can die of different causes but we'd still want their death count to go up, by using this condition it will always add a death to the player and only add a kill to the attacker if it actually is a player
Great!

"but how do i add balance from essentials?"

As mentioned before you will need Vault and Essentials.
If you already have both of them all you need to do is use the %player's balance% expression in one of the lines and make the players gain/lose some money when a kill happens!

Always make sure to set the lines as shown in the final code when updating those values somewhere else in the code, using functions is recommended for that purpose.

Final code:

on join:
  set title of player's scoreboard to "&eMy Server"
  set line 6 of player's scoreboard to "&a"
  set line 5 of player's scoreboard to "&fPlayer: %player%"
  set line 4 of player's scoreboard to "&fMoney: &e%player's balance%"
  set line 3 of player's scoreboard to "&fKills: &c%{kills::%player's uuid%} ? 0%"
  set line 2 of player's scoreboard to "&fDeaths: &c%{deaths::%player's uuid%} ? 0%"
  set line 1 of player's scoreboard to "&7Server Ip: mc.myserver.net"


on death of player:
  if attacker is a player:
    add 1 to {kills::%attacker's uuid%}
    set line 3 of attacker's scoreboard to "&fKills: &c%{kills::%attacker's uuid%} ? 0%"
      set line 4 of attacker's scoreboard to "&fMoney: &e%attacker's balance%"
      add 5 to attacker's balance
  add 1 to {deaths::%victim's uuid%}
  remove 2 from victim's balance
  set line 4 of victim's scoreboard to "&fMoney: &e%victim's balance%"
  set line 2 of victim's scoreboard to "&fDeaths: &c%{deaths::%victim's uuid%} ? 0%"

I hope this tutorial is helpful, let me know if anything is wrong now <3!


Did you find J__00's tutorial helpful?


You must be logged in to comment

  • March 21, 2022, 10:36 a.m. - _tud  

    you don't need PlaceholderAPI and skript-placeholder to use %player's balance%, you only need vault and an economy plugin

    |     
    Aug. 10, 2022, 9:18 a.m. - J__00  

    Fixed, hmu if you see anything wrong!

    |     
  • March 30, 2022, 6:02 p.m. - Gab  

    You also need to toggle the player's scoreboard on.

    |     
    Aug. 10, 2022, 9:18 a.m. - J__00  

    I've been told by the Addon Dev himself that this is not required by default unless you toggle it off, are you sure about that?

    |     
  • Aug. 9, 2022, 4:52 p.m. - steveshat  

    All together this is a pretty awful tutorial. Bad example for beginners.

    |     
  • Aug. 9, 2022, 4:59 p.m. - nylhus  

    Instead of adding the section that sets the variables to 0 if they aren't set, I'd do it in when setting the scoreboard with
    set line 3 of player's scoreboard to "&fKills: %{kills::%player's uuid%}% ? 0

    |     
    Aug. 10, 2022, 9:17 a.m. - J__00  

    I didn't notice your comment but i added the otherwise expression while editing the tutorial, thanks for the criticism <3

    |     
  • Aug. 9, 2022, 5:07 p.m. - ShaneBee  

    Much of the content here is inaccurate, and as the developer of the plugin as well as a member of the community who constantly needs to help people who have issues due to the inaccurate info here, I would like to see it updated.

    a)

    3:
    A scoreboard does NOT require to be "created", you just have toggle it on, set its title and lines which is what this step is about, let's start from the title:
    

    Untrue, a scoreboard does NOT need to be toggled. By default it is on.

    b)
    title should not be set in the while loop. Title should only be set once (before the loop), same with lines that don't change. All you're doing here is sending many unneeded packets to the player for things that aren't changing. With many players online, all you're doing is sending a lot of packets that contain no changes.

    c)

    5.1:
    This will reduce Server Lag and will use less RAM as the server doesn't need to keep the player who left's scoreboard as data and will just clear it.
    

    This is extremely inaccurate. For starters, your code here is just setting the lines/title to null. Its not removing the scoreboard object.
    Also, SkBee manages this internally. When the player quits, their scoreboard is deleted. So again, your code does nothing here.

    These things are massively miss informing the community.

    |     
    Aug. 10, 2022, 9:16 a.m. - J__00  

    I re did most of the tutorial and i'm 99% sure I fixed everything you said, let me know if there are any issues now!

    |     
  • Aug. 9, 2022, 6:31 p.m. - ShaneBee  
    add 1 to {deaths::%victim's uuiid%}
    

    uuid only has 1 "i" not 2... the amount of people copy/pasting your tutorial, then asking why they get errors is climbing.

    |     
    Aug. 10, 2022, 9:15 a.m. - J__00  

    Fixed!

    |     
  • Dec. 14, 2022, 9:30 a.m. - lebombjames  

    how do u add ranks to the scoreboard

    |     
  • June 13, 2023, 10:56 a.m. - sulphinx  

    Dont use intervals for scoreboards, use events.
    Like when you receive, send or check your balance it updates your scoreboard.
    Way better than having to create more threads for "while" sections.

    |