#How to Change NameTag
1 messages · Page 1 of 1 (latest)
couple things. there's the scoreboard objective method which can display directly below their name, or the Java method which requires changing the player's "profile" (search for a snippet by ShaneBee (on his github)
can you explain further on the scoreboard objective method?
i mean, how can i make the scoreboard read a variable saved on skript?
sorry, not scoreboard. I meant (Looks like i was wrong again, it is indeed scoreboard objective). You can change the prefix/suffix of the team and it will update in real timeteam
i tried using team but didnt really get anywhere, can you give me an example in how to apply a team and how it change a nametag sucessfully?
I don't know of an addon to do it other than SkBee (which has a dedicated wiki), or you can use the built-in /scoreboard command. Unfortunately the value of the objective for that player will still be there (you can possibly remove it in newer versions, but unsure how)
Use TAB API
import me.neznamy.tab.api.TabAPI
command /test:
trigger:
nameTagManager = TabAPI.getInstance().getNameTagManager
tabPlayer = TabAPI.getInstance().getPlayer("PlayerName")
nameTagManager.setPrefix(tabPlayer, "PVP ON")
what addon does this require?
the import is unknown to me
i mean, i have the tab plugin, but when i do the skript i get this error message
Line 1
import:
me.neznamy.tab.api.TabAPI
thanks! now its different errors
but imported succesfully
Line 5
nameTagManager = TabAPI.getInstance().getNameTagManager()
Sorry
{_nameTagManager} = .....
no worries! you did like python right? hahaha, changed here, now there's only one error left
me.neznamy.tab.api.TabAPI
command /test:
trigger:
{_nameTagManager} = TabAPI.getInstance().getNameTagManager()
{_tabPlayer} = TabAPI.getInstance().getPlayer(player)
nameTagManager.setPrefix(tabPlayer, "PVP ON")
{_nameTagManager}.setPrefix({_tabPlayer}, "PVP ON")
Maybe i wrong syntax.
set {_nameTagManager} to .....
set {_tabPlayer} to ....
Use
{_nameTagManager}.setPrefix({_tabPlayer}, "PVP ON")
Thanks! Now there's no error messages but also nothing happens...
Please show me full code
"getPlayer()" method uses a player name (string), not a player object.
you can also use player profiles
expression [player] profile name of %player%:
get:
return (expr-1).getPlayerProfile().getName()
set:
set {_player} to expr-1
set {_name} to change value
if length of {_name} > 16:
set {_name} to first 16 characters of {_name}
set {_pro} to {_player}.getPlayerProfile()
{_pro}.setName({_name})
{_player}.setPlayerProfile({_pro})```
no clue if it works with colored stuff but might as well try
you're awesome
worked like a charm
at the end it was like
trigger:
if {pvp.%player%} is not set:
set {pvp.%player%} to false
set {_nameTagManager} to TabAPI.getInstance().getNameTagManager()
set {_tabPlayer} to TabAPI.getInstance().getPlayer(player's name)
{_nameTagManager}.setSuffix({_tabPlayer}, " &c&l[PVP]")
else:
delete {pvp.%player%}
set {_nameTagManager} to TabAPI.getInstance().getNameTagManager()
set {_tabPlayer} to TabAPI.getInstance().getPlayer(player's name)
{_nameTagManager}.setSuffix({_tabPlayer}, " &a&l[PVP]")```
i believe i could set the {_nameTagManager} outside the if though, but whatever, it works!
thanks for the nice idea, i'll save it to another time if i need it
Good! Here is another version of the code in PySpigot
# coding: utf-8
from me.neznamy.tab.api.event.player import PlayerLoadEvent
from me.neznamy.tab.api import TabAPI
from dev.magicmq.pyspigot import PySpigot as ps
from org.bukkit.entity import Player
from org.bukkit import ChatColor, Bukkit
# รับ Instance ของ TAB API
nameTagManager = TabAPI.getInstance().getNameTagManager()
getTabPlayer = lambda targetName: TabAPI.getInstance().getPlayer(targetName)
Ct = lambda string: ChatColor.translateAlternateColorCodes('&', string)
def main(sender, label, args):
targetName = args[0]
prefix = args[1]
if isinstance(sender, Player):
if nameTagManager != None:
tabPlayer = getTabPlayer(targetName)
if tabPlayer:
nameTagManager.setPrefix(tabPlayer, Ct(unicode(prefix)))
return False
def playerLoaded(event): # player in this event is tab player not player
nameTagManager.setPrefix(event.getPlayer(), Ct(u"&4[&6Test&4]&7"))
player = Bukkit.getPlayer(event.getPlayer().getUniqueId())
if player.isOp():
player.sendMessage("Player is loaded")
ps.command.registerCommand(main, "setprefix")
TabAPI.getInstance().getEventBus().register(PlayerLoadEvent, lambda event: playerLoaded(event))
#using /setprefix "player's name" prefix
it does not work with colors nvm lol
what? you can use python?!
bro that would make my life so easier
i'm like learning skript by force
hey Cbop, no no, i mean the nametag above the player head, but anyway we got it now!