CanUsersChatAsync can return false randomly even for players who can chat. Worse still, this is inconsistent behavior, it will sometimes be true, and sometimes be false for the same pair of users.
How we got this to happen: We had some users sitting in a server, when a user joined we called CanUsersChatAsync for the joining player against all players in game and from each user once against the joining user. We had 5 users so this results in 8 calls. We should expect a consistent set of outputs, yet we had one player rejoin twice and on the first join we get:
Note that this implies even in this set of calls that CanUsersChatAsync(A,B) and CanUsersChatAsync(B,A) returned different results for one of our users. Here is our code which called the method on the server:
I’ve also come across this issue of inconsistency. I think if you attach CanUsersChatAsync to the PlayerAdded connection, it will return false no matter what. But if you yield for a few seconds and then check CanUsersChatAsync, it will return true or the actual result.
This is possible, our connection is on the client and then the client invokes the server. Its possible this inherent delay is why its fine 90% of the time.
It seems like you’re attempting to design something that will cache the CanUsersChat evaluation when a player joins the server. Unfortunately, not enough information is available during player join that make the call if the new arriving player can chat with other players immediately.
In most cases, its unlikely you need to cache the value of this evaluation if you intend to use it as a gating check when a user interacts with your social features. If you do need to cache it, you could cache the true responses only.
Caching the false results in this way may not be accurate for players who age check during that gameplay session.
If you must know the pairwise evaluation results immediately, unfortunately there does not appear to be an event to cleanly bind to. CanUserChatAsync is likely to be true while waiting for all the CanUserChatAsync results which could be a hint that there may be pairs after a few moments.
Ok no worries. We just periodically re-check the result and override any cached false with true but not the other way around (afaik it can never false report a true).