Problem using Teams to toggle name tag visibility

Discussion in 'Plugin Development' started by getAmogusProgrammer, Jun 24, 2021.

Thread Status:
Not open for further replies.
  1. Hey all,

    I've been working on an Among Us plugin lately, and I've encountered problems with name tag visibility.

    In a game, there are two teams : the crewmates (crew) and the impostors (imps). I don't want the crewmates to see anyone's name tags, as it would reveal an impostor's identity, should they vent.

    Since I'm no expert in plugin development, I chose to manipulate name tag visibility with teams.

    In my plugin, every Among Us game is assigned to a lobby class, which has its own Scoreboard, along with a playerlist of players who each have their own different scoreboards. So I register teams on the lobby's scoreboard, and display every player's various mission on their own scoreboards.

    this is the code I run when I create a new lobby :


    Scoreboard board = lobby.getLobbyScoreboard();

    board.registerNewTeam("crew");
    board.registerNewTeam("imps");
    board.registerNewTeam("ghosts");

    team = board.getTeam("ghosts");
    team.setCanSeeFriendlyInvisibles(true);

    team = board.getTeam("imps");
    team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OTHER_TEAMS);

    team = board.getTeam("crew");
    team.setOption(Team.Option.NAME_TAG_VISIBILITY, Team.OptionStatus.FOR_OWN_TEAM);
    team.setCanSeeFriendlyInvisibles(true);


    and when I connect someone to a team:

    public static void joinTeam(LobbyPlayer lobbyPlayer, String teamName) {
    leaveTeams(lobbyplayer);
    Player player = lobbyPlayer.getPlayer();
    Team team=lobbyplayer.getLobby().getLobbyScoreBoard().getTeam(teamName);
    team.addEntry(player.getName());
    }


    The problem here is that when I add an entry to a team, it does show their name in the right team, however the crewmate can still the impostor's name tag, which makes me believe that I'm doing something wrong and the game isn't told to send player packets.

    Question: Does a player's scoreboard need to be set to their lobby's (aka scoreboard where teams are registered) in order for the TeamOptions to work? Should I instead work with tagAPI?

    Thanks!
     
  2. Offline

    davidclue

Thread Status:
Not open for further replies.

Share This Page