RequestUserInformation() public static method

requests information about a user - persona name & avatar

if bRequireNameOnly is set, then the avatar of a user isn't downloaded

- it's a lot slower to download avatars and churns the local cache, so if you don't need avatars, don't request them

if returns true, it means that data is being requested, and a PersonaStateChanged_t callback will be posted when it's retrieved

if returns false, it means that we already have all the details about that user, and functions can be called immediately

public static RequestUserInformation ( CSteamID steamIDUser, bool bRequireNameOnly ) : bool
steamIDUser CSteamID
bRequireNameOnly bool
return bool
Example #1
0
        internal static async Task CacheUserInformationAsync(SteamId steamid, bool nameonly)
        {
            if (SteamFriends.RequestUserInformation(steamid, nameonly))
            {
                await Task.Delay(100);

                while (SteamFriends.RequestUserInformation(steamid, nameonly))
                {
                    await Task.Delay(50);
                }
                await Task.Delay(500);
            }
        }
        /// <summary>
        /// Works also for players that aren't friends
        /// </summary>
        public static void RequestName(this Friend player, Action <string> onRetrived)
        {
            if (!SteamFriends.RequestUserInformation(player.Id, true))
            {
                onRetrived?.Invoke(player.Name);
            }
            else
            {
                var playerId = player.Id;
                SteamFriends.OnPersonaStateChange += SteamFriends_OnPersonaStateChange;

                void SteamFriends_OnPersonaStateChange(Friend friendChanged)
                {
                    if (playerId == friendChanged.Id)
                    {
                        SteamFriends.OnPersonaStateChange -= SteamFriends_OnPersonaStateChange;
                        onRetrived?.Invoke(friendChanged.Name);
                    }
                }
            }
        }