Scoreboard team prefix
#1
Question 
Since Minecraft, by default, limits the username to 16 characters, it is impossible to create "prefixes" correctly using cPlayer:SetCustomName(name) function. In Bukkit/Minecraft vanilla this is quickly resolved with scoreboard teams using prefix/sufix, which characters limit is 32

As I'm new to Cuberite I tried to do the same in it, but without success. So after many tries i decided to look at the source code on GitHub and noticed that the team prefix on the scoreboard is not used anywhere in the code.

So, is there any way to do this in Cuberite?


Code:
function LoadScoreboard(Player)
    -- Scoreboard
    Scoreboard = Player:GetWorld():GetScoreBoard()

    if Scoreboard:GetTeam("Admin") == nil then
        Scoreboard:RegisterTeam("Admin", "Admin", "§c[Admin]", "")
    end

    Scoreboard:GetTeam("Admin"):AddPlayer(Player:GetName())
end
Reply
Thanks given by:
#2
Hi, welcome to the forum!

In Cuberite you can give a rank their own prefix and suffix. If you've got the Core plugin enabled you can easily change this in the webadmin under the Core's Rank page. If you want to do it in code you can use the cRankManager:SetRankVisuals function.
Reply
Thanks given by: kazhiel
#3
(03-15-2023, 09:42 PM)NiLSPACE Wrote: Hi, welcome to the forum!

In Cuberite you can give a rank their own prefix and suffix. If you've got the Core plugin enabled you can easily change this in the webadmin under the Core's Rank page. If you want to do it in code you can use the cRankManager:SetRankVisuals function.

Hi NiLSPACE, and thanks for replying Big Grin

I had already looked at these functions in API Docs, but the point here is about the Scoreboard and not the Ranks. Suppose I wanted to create a minigame in which each team has a different prefix/suffix (Ex: BedWars or Team Skywars), how would this be applied?

Going back to the topic of ranks, they just change the color of the name in the tab and don't add a prefix/suffix (Which is only applied in chat). If you look at the "Player.cpp" code in the "GetPlayerListName" function, you will notice that it only send the color rank for "SendPlayerListAddPlayer" function

I don't know if it was on purpose or the development team forgot to add this feature, but in the end this ends up making it impossible to customize more detailed what the Scoreboard has to offer

Again, thanks for replyingBig Grin
Reply
Thanks given by:
#4
Ah, because of your example with 'Admin' I assumed you wanted prefixes for roles.

The prefix and suffix missing in the player list definitely seems like an oversight. Perhaps that's done because of the character limit, but it's not documented at least.

The scoreboard has always been a bit of a mystery to me. I looked through the protocol files, but I can't find anything related to teams, so I'm guessing it hasn't been implemented.
Reply
Thanks given by: kazhiel
#5
(03-17-2023, 02:48 AM)NiLSPACE Wrote: Ah, because of your example with 'Admin' I assumed you wanted prefixes for roles.

Haha don't worry, the example I used gave this impression. Sorry Smile

Quote:The prefix and suffix missing in the player list definitely seems like an oversight. Perhaps that's done because of the character limit, but it's not documented at least.

Definitely, exceeding the 16 character limit may cause other clients to crash

Quote:The scoreboard has always been a bit of a mystery to me. I looked through the protocol files, but I can't find anything related to teams, so I'm guessing it hasn't been implemented.

I think for everyone it is, Bukkit/Sponge for example have a per-player Scoreboard system (That is not saved to disk)

In general, scoreboard teams are just "placeholders" that can contain special functions/flags for players who are in them, such as: Friendly-fire; Players can see teammates with invisibility effectCollision can be ignored between teammates; Enemies name can be in another color to help distinguish enemy/teammat

But the most important feature of teams are the prefixes and suffixes, as they have the ability to exceed the 16-character limit. The limit of each is 16 too, but adding them plus the player name limit, we ended up having a username with 48 characters

This is how player prefixes such "Admin" or "VIP" before username are done without bypassing default 16 limit in Bukkit/Sponge based servers.

I'll leave the suggestion of this implementation Smile

Again, thanks for the responseBig Grin
Reply
Thanks given by:




Users browsing this thread: 6 Guest(s)