View Single Post
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 03-15-2016 , 10:09   Re: Convert STEAMID to Steam Community ID
Reply With Quote #346

Quote:
Originally Posted by Neuro Toxin View Post
This is what I use...

PHP Code:
    function CommunityID2SteamID($communityid)
    {
        
$steamid 'STEAM_1:';
        
$z = ($communityid 76561197960265728) / 2;

        if (
$z floor($z) == 0.5)
            
$steamid.='1:';
        else
            
$steamid.='0:';

        
$steamid.=floor($z);
        return 
$steamid;
    }

    function 
SteamID2CommunityID($steamid
    { 
        
$parts explode(':'str_replace('STEAM_''' ,$steamid)); 
        return 
bcadd(bcadd('76561197960265728'$parts['1']), bcmul($parts['2'], '2')); 
    } 
Just be aware that this will fail on 32-bit systems as PHP uses 32-bit integers for integer math on them. Unless PHP changed this in the later 5.x versions or in 7.0.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline