我一直在关注 Steam 文档,但我已经到了需要根据 Steam ID 检索玩家名称的地步,而 Steam 在他们的文档中有一个功能:
const char *pchName = SteamFriends()->GetPersonaName(steamID);
但是 Visual Studio 表示没有具有该数量参数的函数。唯一可接受的功能是
const char *pchName = SteamFriends()->GetPersonaName();
它应该返回本地玩家的角色名称(确实如此)。我可以想办法从每个用户那里获取它并在登录时将其存储在我的服务器上,但看起来确实应该可行。我应该如何获取 friend 的 uint64 SteamID 的角色名称?他们最近是否更改了此功能?
我使用源代码中的 Unreal Engine 4.7.6 和 Steam API 1.30。
最佳答案
显然 Steam 不擅长更新他们的文档。我打开了 isteamfriends.h
header ,发现了这个 Steam 文档中从未提及的函数:
// 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 分钟前,我真的直接从他们的实时文档中提取了这一行,但它不起作用。
const char *pchName = SteamFriends()->GetPersonaName(steamID);
那么正确的做法是:
const char *pchName = SteamFriends()->GetFriendsPersonaName(steamID);
关于c++ - Steam API 获取角色名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30333460/