c++ - Steam API 获取角色名称

标签 c++ steam unreal-engine4 steamworks-api

我一直在关注 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/

相关文章:

c++ - 虚幻引擎中四元数旋转云台问题

c++ - 为什么 _beginthreadex 因 ERROR_INVALID_ACCESS 而失败?

c++ - 如何通过 << 运算符将参数传递给函数?

java - 为什么用 C++ 编写的 BRMS 不如用 Java 编写的 BRMS 有用?

data-science - 关于 Valve 的 Steam Web API 的一些问题 - 获取 Dota 2 比赛历史

steam - 如何从 Valve 服务器查询获取玩家 SteamID?

c++ - C11 & C++11 扩展和通用字符转义

linux - 管道的奇怪 Steam 更新行为

unreal-engine4 - 将 PlasticSCM 与虚幻引擎 4 结合使用

c++ - 虚幻引擎 4.18.2 "no default constructor exists for class "UUserWidget""