发新话题
打印

[技术文档] 如何转换 steamid 为 steam 好友id

如何转换 steamid 为 steam 好友id

转贴来自: http://forums.alliedmods.net/showthread.php?t=60899

PS:
这并不是官方公布的方法,而是一个玩家的意外收获,
当我们使用 steam 好友功能时, 这个转换非常实用,
因为steam的好友id实在太长而且难记
复制内容到剪贴板
CPP 代码:
  1. __int64 GetFriendID( const char *pszAuthID )
  2. {
  3.     if(!pszAuthID)
  4.         return 0;
  5.  
  6.     int iServer = 0;
  7.     int iAuthID = 0;
  8.  
  9.     char szAuthID[64];
  10.     strcpy_s(szAuthID, 63, pszAuthID);
  11.  
  12.     char *szTmp = strtok(szAuthID, ":");
  13.     while(szTmp = strtok(NULL, ":"))
  14.     {
  15.         char *szTmp2 = strtok(NULL, ":");
  16.         if(szTmp2)
  17.         {
  18.             iServer = atoi(szTmp);
  19.             iAuthID = atoi(szTmp2);
  20.         }
  21.     }
  22.  
  23.     if(iAuthID == 0)
  24.         return 0;
  25.  
  26.     __int64 i64friendID = (__int64)iAuthID * 2;
  27.  
  28.     //Friend ID's with even numbers are the 0 auth server.
  29.     //Friend ID's with odd numbers are the 1 auth server.
  30.     i64friendID += 76561197960265728 + iServer;  
  31.  
  32.     return i64friendID;
  33. }

TOP

北京到布达佩斯机票

提示: 作者被禁止或删除 内容自动屏蔽

TOP

发新话题