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

    Supporter +

    Joined:
    Sep 7, 2017
    Messages:
    1,529
    Likes Received:
    101
    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
Loading...