View Single Post
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 12-14-2012 , 13:23   Re: Get CommunityID (SteamID64) String
Reply With Quote #17

Code:
bool:GetFriendID(String:AuthID[], String:FriendID[], size)
{
    ReplaceString(AuthID, strlen(AuthID), "STEAM_", "");
    if (StrEqual(AuthID, "ID_LAN"))
    {
        FriendID[0] = '\0';
        return false;
    }
    decl String:toks[3][16];
    new upper = 765611979;
    new String:temp[12], String:carry[12];

    ExplodeString(AuthID, ":", toks, sizeof(toks), sizeof(toks[]));
    new iServer = StringToInt(toks[1]);
    new iAuthID = StringToInt(toks[2]);
    new iFriendID = (iAuthID*2) + 60265728 + iServer;

    if (iFriendID >= 100000000)
    {
        Format(temp, sizeof(temp), "%d", iFriendID);
        Format(carry, 2, "%s", temp);
        new icarry = StringToInt(carry[0]);
        upper += icarry;

        Format(temp, sizeof(temp), "%d", iFriendID);
        Format(FriendID, size, "%d%s", upper, temp[1]);
    }
    else
    {
        Format(FriendID, size, "765611979%d", iFriendID);
    }

    return true;
}
this is way better than doing big number additions with strings
__________________
Taking private C++/PHP/SourcePawn requests, PM me.

Last edited by Zephyrus; 12-14-2012 at 13:23.
Zephyrus is offline