Show player as ghost to another player

Discussion in 'Plugin Development' started by marwzoor, May 19, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    marwzoor

    Hey guys!

    I was just wondering about ScoreboardTeams and how the packet "PacketPlayOutScoreboardTeam" works.

    The scenario is like this:

    Player A is invisible to Player B, but when Player A gets close to Player B then Player A should be visible as a ghost to Player B.

    I already use teams to add a prefix and suffix to the players' names so I don't want it to interfere. That's why I thought I'd might use packets.

    So what if I create a packet that is saying that the two players are in the same team and that the team they are in have canSeeFriendlyInvisibles() set to true. Would that work? Can anyone help me out on this? I am shrugging my head right now...

    Thanks in advance,
    Marwzoor
     
  2. Offline

    Garris0n

    The client will still only work with one scoreboard at a time, regardless of how many packets are used.
     
  3. Offline

    caseif

    I took a look at the source file, and here's what I was able to figure out in terms of its globals:

    a represents the name of the team. For your purposes, this should be arbitrary.
    b represents the display name of the team. Again, for your purposes, arbitrary.
    c represents the team prefix. Arbitrary.
    d represents the team suffix. Arbitrary.
    e represents an arraylist of players on the team. I wasn't able to figure out what type, but I would assume either Player or String. You should populate this with the respective objects for Players A and B.
    I wasn't able to figure out what f was. Looks to be some sort of data flag. All I know is that it's an int. Same goes for g.

    I would assume that either f or g would be your best bet for setting team visibility. I suppose you'd just have to play with them and see what happens.

    I also feel the need to mention that you may run into some issues if the player receiving the packet is already on a team. Worst case scenario, it could confuse the client and cause it to be kicked.

    Anyway, let me know how this turns out. It seems pretty neat, and I want to know whether you're able to get it working. Best of luck!
     
  4. Offline

    xTigerRebornx

    ShadyPotato Perhaps http://wiki.vg/Protocol#Teams will help clarify the last 2? EDIT: f looks to be the 'Mode' field, since it is the thing being compared closest to the values it can have (0, 2) in the constructor
     
  5. Offline

    marwzoor

    Thanks for the help! I will definitely let you know how it goes! :)

    I actually got it to work.

    View attachment 19773
    This is from my main account and is me invisible holding an iron ingot.


    View attachment 19775
    This is me from my alt account.

    As you can see my main account thinks I am not in a team with canSeeFriendlyInvisibles enabled. My alt account thinks so though.

    I have also tested making a "real" team without packets, and at that time I saw myself transparent on both of my accounts.

    Okey so now the only issue left is that I use teams to add Prefixes and Suffixes showing the player's Level and Guild. I have no idea how I would have a different prefix and suffix shown on both Player A and B if they are in the same team.

    To clearify:

    if Player A is a Level 32 Archer and is in a guild with the tag MRW and Player B is a Level 4 Warrior.

    When I check the tab list then both Player A and Player B will be shown as: (MRW) <name> Level 32 Archer

    How would I go about changing the prefix and suffix "outside" of teams?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  6. Offline

    NerdsWBNerds


    Would you mind posting what code you used to get it working?
     
  7. Offline

    caseif

    Since you've already entered the world of packets, you could probably modify the player list packet to include the prefixes. Not quite sure what it is, though, or if it even exists.

    Edit: Apparently there's a Player#setPlayerListName(String) method. Huh, TIL.
     
  8. Offline

    marwzoor

    Yeah that could work! :) didn't even think of that haha.

    Now the only issue is the prefix and suffix above the player's head...
     
  9. Offline

    marwzoor

    It's like deeply implemented into my plugin haha. If I would have any general code for it I could probably do it. If you're lucky I'll put something together for ya!
     
Thread Status:
Not open for further replies.

Share This Page