• Community ID from steamid
    5 replies, posted
I am trying to get a users Community ID through there steamid with the following code: [code] $steamid_split = explode(":", $data['SteamID']); $comm_id = ($steamid_split[2] * 2) + 76561197960265728 + $steamid_split[1]; $comm_id = number_format($comm_id, 0, "" , ""); echo $comm_id; [/code] Let's just say $data['SteamID'] = STEAM_0:1:20189445 But after running it through number_format to get it away from scientific notation the number is wrong (5 off what it should be). The end result should be: 76561198000644619
I got some code for this somewhere, let me find it [editline]12:12PM[/editline] [php] $sidpart = substr($banrow['steam_id'],strpos($banrow['steam_id'], 'STEAM_:0:'),1); $community_id = ((substr($banrow['steam_id'], 10)) * 2) + 1197960265728 + (substr($banrow['steam_id'], 8, 1)); $community_id= '7656'.$community_id; $community_id += $sidpart; echo 'Community ID: '.$community_id; [/php] [editline]12:14PM[/editline] Replace $banrow with $data and you're good.
This also gives me the data in scientific notation (7.6561198000645E+16) and when I try and convert it, the end data is still wrong.
Odd, works for me in [url]http://xvs.jmazouri.com/?page=bans[/url] (click the guy's name) Perhaps it's because i'm using it as a string.
The Steam Community ID is a 64-Bit integer. If you attempt to use a 64-bit integer on a 32-bit server, you'll end up with the scientific notation. Apparently, even the 64-Bit version of PHP for Windows does not support 64-bit integers due to the underlying C code. The 64-Bit version of PHP for Linux does support the 64-Bit integers, however. As for methods to get this to work, you can try different PHP Math extensions which appear support 64-bit integers better. You can try extensions such as [url=http://www.php.net/manual/en/book.gmp.php]GMP[/url] or [url=http://www.php.net/manual/en/book.bc.php]BC Math[/url].
[QUOTE=deadeye536;23645533]The Steam Community ID is a 64-Bit integer. If you attempt to use a 64-bit integer on a 32-bit server, you'll end up with the scientific notation. Apparently, even the 64-Bit version of PHP for Windows does not support 64-bit integers due to the underlying C code. The 64-Bit version of PHP for Linux does support the 64-Bit integers, however. As for methods to get this to work, you can try different PHP Math extensions which appear support 64-bit integers better. You can try extensions such as [url=http://www.php.net/manual/en/book.gmp.php]GMP[/url] or [url=http://www.php.net/manual/en/book.bc.php]BC Math[url].[/QUOTE] Thanks, it works perfectly now.
Sorry, you need to Log In to post a reply to this thread.