1. Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the comminuty!

    Now, what are you waiting for? Join the community now!

Dismiss Notice
This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Sorted Tablist

Discussion in 'Snippets' started by ShaneBee, Jan 12, 2019.

  1. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    Okay so I got this working, but if Im not mistaken it will not work with scoreboards like Skellett, since Skellett I believe overrides the teams
    This requires Skript Mirror

    Custom Syntaxes:
    (This can be placed at the top of your script or in another script that loads before the one that is using it)

    Code (Skript):
    1. #! register a new team (group) for your tablist, alphabically sorted in your tablist !#
    2. effect [(1¦un)]register team %string%:
    3.     trigger:
    4.         set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    5.         if parse mark is 1:
    6.             {_score}.getTeam(expression-1).unregister()
    7.         else:
    8.             {_score}.registerNewTeam(expression-1)
    9.  
    10. #! Get/set the prefix/suffix of your tablist groups !#
    11. #! I added [custom] here as it may not work well with Skellett !#
    12. expression [custom] (1¦prefix|2¦suffix) of team %string%:
    13.     get:
    14.         if parse mark is 1:
    15.             set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    16.             return {_score}.getTeam(expression-1).getPrefix()
    17.         else if parse mark is 2:
    18.             set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    19.             return {_score}.getTeam(expression-1).getSuffix()
    20.     set:
    21.         if parse mark is 1:
    22.             set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    23.             {_score}.getTeam(expression-1).setPrefix(change value)
    24.         else if parse mark is 2:
    25.             set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    26.             {_score}.getTeam(expression-1).setSuffix(change value)
    27.  
    28. #! get/set the team of a player !#
    29. expression team of %player%:
    30.     get:
    31.         return expression-1.getScoreboard().getPlayerTeam(expression-1).getName()
    32.     set:
    33.         set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    34.         {_score}.getTeam(change value).addPlayer(expression-1)
    35.  
    36. #! Checks if a team is already registered !#
    37. condition team %string% (1¦is set|2¦(is not|isn't) set):
    38.     check:
    39.         set {_score} to server.getServer().getScoreboardManager().getMainScoreboard()
    40.         if {_score}.getTeam(expression-1):
    41.             if parse mark is 1:
    42.                 continue
    43.         else:
    44.             if parse mark is 2:
    45.                 continue
    Example of how I am using it:
    Code (Skript):
    1. on load:
    2.     if team "A-OWNER" isn't set:
    3.         register team "A-OWNER"
    4.         set prefix of team "A-OWNER" to "&9OWNER "
    5.     if team "B-ADMIN" isn't set:
    6.         register team "B-ADMIN"
    7.         set prefix of team "B-ADMIN" to "&cADMIN "
    8.     if team "C-MOD" isn't set:
    9.         register team "C-MOD"
    10.         set prefix of team "C-MOD" to "&dMOD "
    11.     if team "D-PLAYER" isn't set:
    12.         register team "D-PLAYER"
    13.         set prefix of team "D-PLAYER" to "&7PLAYER "
    14.  
    15. on join:
    16.     if player has permission "rank.owner":
    17.         set team of player to "A-OWNER"
    18.     else if player has permission "rank.admin":
    19.         set team of player to "B-ADMIN"
    20.     else if player has permission "rank.mod":
    21.         set team of player to "C-MOD"
    22.     else:
    23.         set team of player to "D-PLAYER"
    24.  
     
    #1 ShaneBee, Jan 12, 2019
    Last edited: Jan 12, 2019
  2. L0v0lup

    L0v0lup Member

    Joined:
    Feb 19, 2017
    Messages:
    23
    Likes Received:
    2
    Hi there, nice Skript, pretty much what i was looking for.
    But it doesnt work on 1.16 anymore and i dont know much about SkMirror / SKReflect to fix it myself.
    Here is the error:

    Code (Text):
    1. [12:10:52 WARN]: [Skript] method CraftScoreboard#registerNewTeam called with (A-OWNER (String)) returned [email protected] (CraftTeam), which could not be converted to Boolean
    2. [12:10:52 WARN]: [Skript] method CraftScoreboard#registerNewTeam called with (B-ADMIN (String)) returned [email protected] (CraftTeam), which could not be converted to Boolean
    3. [12:10:52 WARN]: [Skript] method CraftScoreboard#registerNewTeam called with (C-MOD (String)) returned [email protected] (CraftTeam), which could not be converted to Boolean
    4. [12:10:52 WARN]: [Skript] method CraftScoreboard#registerNewTeam called with (D-PLAYER (String)) returned [email protected] (CraftTeam), which could not be converted to Boolean
     
  3. Ankle Boiii

    Ankle Boiii Member

    Joined:
    Jun 27, 2020
    Messages:
    3
    Likes Received:
    0
    Odd, it seems to work for me - I'm using a different system, but I can get the scoreboard (I use the main scoreboard) and can register a new team with a string. Like so:

    Code (Text):
    1. set {_score} to Bukkit.getServer().getScoreboardManager().getMainScoreboard()
    2. {_score}.registerNewTeam("team name")
    3. # modifications here
     
  4. ShaneBee

    Moderator Resource Staff Supporter + Addon Developer

    Joined:
    Sep 7, 2017
    Messages:
    2,179
    Likes Received:
    218
    I have never once seen an error like this.... are you using skript-mirror or reflect?
    If skript-mirror ... which version?
    If lower than 2.0.0, I recommend upgrading or just switching over to skript-reflect.
     
  5. DarkKingMW

    DarkKingMW New Member

    Joined:
    Jun 22, 2018
    Messages:
    8
    Likes Received:
    0
    hey i have the server version 1.16.5 and the plugins you need on the latest version script, skbee and script-reflect there are no errors in the console but the players don't get a prefix in the tablist
     

Share This Page

Loading...