Steam API 获取角色名称 [英] Steam API getting persona name
问题描述
我一直在关注 Steam 文档,但我已经到了需要根据 Steam ID 检索玩家姓名的地步,Steam 在他们的文档中提供了一个功能:
I have been following the Steam documentation to a t, but I have gotten to the point where I need to retrieve player names based on the steam ID, and Steam has a function for this in their documentation:
const char *pchName = SteamFriends()->GetPersonaName(steamID);
然而,Visual Studio 表示没有具有这么多参数的函数.唯一可以接受的函数是
However Visual Studio says that there is no function with that number of arguments. The only acceptable function is
const char *pchName = SteamFriends()->GetPersonaName();
应该返回本地玩家的角色名称(确实如此).我可以想办法从每个用户那里获取它并在登录时将其存储在我的服务器上,但看起来这确实应该有效.我应该如何获得朋友的 uint64 SteamID 的角色名称?他们最近是否更改了此功能?
Which is supposed to return the local player's persona name (which it does). I can make a way to get this from every user and store it on my server on login, but it sure seems like this should work. How am I supposed to get the persona name for a friend's uint64 SteamID? Did they change this function recently?
我正在使用来自 Steam API 1.30 的 Unreal Engine 4.7.6.
I am using Unreal Engine 4.7.6 from source with Steam API 1.30.
推荐答案
显然 Steam 不擅长更新他们的文档.我打开了 isteamfriends.h
头文件,发现这个功能在 Steam 文档中从未提及:
Apparently Steam is bad at updating their documentation. I opened up the isteamfriends.h
header and found this function that is never mentioned in the Steam docs:
// returns the name another user - guaranteed to not be NULL.
// same rules as GetFriendPersonaState() apply as to whether or not the user knowns the name of the other user
// note that on first joining a lobby, chat room or game server the local user will not known the name of the other users automatically; that information will arrive asyncronously
//
virtual const char *GetFriendPersonaName( CSteamID steamIDFriend ) = 0;
来吧,Steam...我在大约 30 分钟前直接从他们的实时文档中删除了这条线,但它不起作用.
Come on, Steam... I literally pulled this line directly from their live docs about 30 minutes ago, and it doesn't work.
const char *pchName = SteamFriends()->GetPersonaName(steamID);
<小时>
那么正确的方法是:
So the correct way then is:
const char *pchName = SteamFriends()->GetFriendsPersonaName(steamID);
这篇关于Steam API 获取角色名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!