You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a player connects he gets a IPlayer instance with a particular Id.
When he disconnects and reconnects back later he gets another IPlayer instance with different Id but the two IPlayer instance are equal.
It seems that the Equal() is not based on content of the IPlayer instance but on something else because the behavior isn't 100% consistant.
Reproduction steps
Create and in Alt.OnPlayerConnect event that add the IPlayer instance to an HashSet and display an error if the add returned false:
public static class LoginManager
{
private static HashSet<IPlayer> _players = new();
public static void Init()
{
Alt.OnPlayerConnect += (IPlayer client, string reason) =>
{
Alt.Log($"Client {client.Id} Connected");
if (!_players.Add(client))
Alt.Log("IPlayer already in HashSet");
};
}
}
This seems like a breaking change for others if the maintainer overrides IPlayer.Equals() in the module. How about you override it on your side to add your own checks?
Description of the problem
When a player connects he gets a IPlayer instance with a particular Id.
When he disconnects and reconnects back later he gets another IPlayer instance with different Id but the two IPlayer instance are equal.
It seems that the Equal() is not based on content of the IPlayer instance but on something else because the behavior isn't 100% consistant.
Reproduction steps
Create and in Alt.OnPlayerConnect event that add the IPlayer instance to an HashSet and display an error if the add returned false:
Result:
Here it takes me 2 reconnects to have equal IPlayer instances but sometimes it can take morre or less attempts.
Expected behaviour
Different IPlayer instances with different Id should not be equal.
Additional context
No response
Operating system
Windows 10 21H2
Version
release/10.8
The text was updated successfully, but these errors were encountered: