Add OnPlayerAdd/Remove team hooksSuggestion
Hello uMod developers!
Current shared hooks are don't allow to achieve needs behaviour in plugin.
Can you add some new hooks for in-game teams?
Something like:
OnTeamPayerAdded(RelationshipManager.PlayerTeam team, BasePlayer player) (when player already added to the team)
and
OnTeamPlayerRemoved(RelationshipManager.PlayerTeam team, ulong playerID) (when player already removed from the team)?
I think it can be added in methods of PlayerTeam class:
public bool AddPlayer(BasePlayer player)
{
  ulong num = player.userID;
  if (this.members.Contains(num))
  {
    return false;
  }
  if (player.currentTeam != 0)
  {
    return false;
  }
  if (this.members.Count >= RelationshipManager.maxTeamSize)
  {
    return false;
  }
  player.currentTeam = this.teamID;
  this.members.Add(num);
  RelationshipManager.Instance.playerToTeam.Add(num, this);
  this.MarkDirty();
  player.SendNetworkUpdate(BasePlayer.NetworkQueue.Update);
  //------------- it think here----------------
  Interface.CallHook("OnTeamPlayerAdded", this, basePlayer);
  //-----------------------------
  return true;​
}
public bool RemovePlayer(ulong playerID)
{
  if (!this.members.Contains(playerID))
  {
    return false;
  }
  this.members.Remove(playerID);
  RelationshipManager.Instance.playerToTeam.Remove(playerID);
  BasePlayer basePlayer = RelationshipManager.FindByID(playerID);
  if (basePlayer != null)
  {
    basePlayer.ClearTeam();
    basePlayer.BroadcastAppTeamRemoval();
  }
  if (this.teamLeader == playerID)
  {
    if (this.members.Count <= 0)
    {
      this.Disband();
    }
    else
    {
      this.SetTeamLeader(this.members[0]);
    }
  }
  this.MarkDirty();
  //------------- it think here----------------
  Interface.CallHook("OnTeamPlayerRemoved", this, playerID);
  //-----------------------------
  return true;
}

If you will have time just look at this please!
Thanks in advance!
I think there are a few hooks already for it
5b6ed4c9ac8e4.jpg misticos
I think there are a few hooks already for it

Thanks for the answer!
Im tryed to use OnTeamUpdated hook - but it starts to spam in console, when i use it once with one player... I think its happening, because hook is in the method which update all info about team (inc markers on map and etc...).

Im tryed to use OnTeamUpdate hook - but actually there are no team changes was when this hook is called...

Same problem with "team changes" in hooks like OnTeamLeave and OnTeamAcceptInvite and OnTeamKick...
All these hooks сalled when the team itself has not yet been changed...

So for most situations, these hooks (which I suggested) would be much more convenient.
Thanks.

Merged post

Or it can be one hook instead of two.
Like OnTeamChanged(RelationshipManager.PlayerTeam team, ulong playerID, bool state), when was added player to team (state == true) or removed from team (state == false), but all changes are already in team itself.
If you want a hook call when stuff has already changed, use NextFrame method so that it'll be called next frame.
5b6ed4c9ac8e4.jpg misticos
If you want a hook call when stuff has already changed, use NextFrame method so that it'll be called next frame.

Thanks for the answer...
If honestly im don't clearly understand how to do that. Can you show me a small example of this trick, please?
Thank you!

private void AnyMethod() {
NextFrame(() => {
//Todo
});
}
5b6ed4c9ac8e4.jpg misticos
private void AnyMethod() {
NextFrame(() => {
//Todo
});
}

Thank you! But my my suggestion is still stands. These hooks would be much more convenient!
Thank you again!