Raised This Month: $51 Target: $400
 12% 

Get CommunityID (SteamID64) String


Post New Thread Reply   
 
Thread Tools Display Modes
11530
Veteran Member
Join Date: Sep 2011
Location: Underworld
Old 12-21-2012 , 14:34   Re: Get CommunityID (SteamID64) String
Reply With Quote #31

Cool, I'll test it properly some other time, but I'll update the OP with it for now.

Looking at it briefly though, AuthID[x] without checking the length might cause some problems. The check needs to be out to truncate the string, but added so AuthID[x] won't bug out. Also what about SteamIDs where iFriendID >= 300000000 etc.? I like future-proofing functions, no matter how far in the future it is, which is why my original function did it like that.
__________________

Last edited by 11530; 12-21-2012 at 14:35.
11530 is offline
Zephyrus
Cool Pig B)
Join Date: Jun 2010
Location: Hungary
Old 12-21-2012 , 14:59   Re: Get CommunityID (SteamID64) String
Reply With Quote #32

Quote:
Originally Posted by 11530 View Post
Cool, I'll test it properly some other time, but I'll update the OP with it for now.

Looking at it briefly though, AuthID[x] without checking the length might cause some problems. The check needs to be out to truncate the string, but added so AuthID[x] won't bug out. Also what about SteamIDs where iFriendID >= 300000000 etc.? I like future-proofing functions, no matter how far in the future it is, which is why my original function did it like that.
PHP Code:
stock bool:GetCommunityID(String:AuthID[], String:FriendID[], size)
{
    if(
strlen(AuthID) < 11 || AuthID[0]!='S' || AuthID[6]=='I')
    {
        
FriendID[0] = 0;
        return 
false;
    }

    new 
iUpper 765611979;
    new 
iFriendID StringToInt(AuthID[10])*60265728 AuthID[8]-48;

    new 
iDiv iFriendID/100000000;
    new 
iIdx 9-(iDiv?iDiv/10+1?0);
    
iUpper += iDiv;
    
    
IntToString(iFriendIDFriendID[iIdx], size-iIdx);
    
iIdx FriendID[9];
    
IntToString(iUpperFriendIDsize);
    
FriendID[9] = iIdx;

    return 
true;

future and idiot proof, altho having that strlen for authid slows down the code by 0.2sec in case of 10 million runs altho i dont think that passing non-steamids should be checked at all, its like decl vs new, if you know what you are doing with your own variable, use decl otherwise use new

anyway without strlen the code performs still the same as my original one
__________________
Taking private C++/PHP/SourcePawn requests, PM me.

Last edited by Zephyrus; 12-21-2012 at 15:02.
Zephyrus is offline
pheadxdll
AlliedModders Donor
Join Date: Jun 2008
Old 02-23-2013 , 19:31   Re: Get CommunityID (SteamID64) String
Reply With Quote #33

Quote:
Originally Posted by Zephyrus View Post
PHP Code:
    new iIdx 9-(iDiv?iDiv/10+1?0); 
Typo!
PHP Code:
    new iIdx 9-(iDiv?iDiv/10+1:0); 
But it works great, I was having trouble with the stock in dynamic motd and this seems to work well. Thanks!
__________________
pheadxdll is offline
Alienmario
Senior Member
Join Date: Aug 2013
Old 11-29-2013 , 17:05   Re: Get CommunityID (SteamID64) String
Reply With Quote #34

Took the old profile viewer and replaced it with this code so you don't have to.
Usage: Type "!profile <Steam ID, UserID, Username>"

Edit: added new fixed version, which works around a motd bug, where it fails to load a new page.
Attached Files
File Type: sp Get Plugin or Get Source (profile.sp - 857 views - 1.8 KB)
File Type: sp Get Plugin or Get Source (profile_fixed.sp - 603 views - 2.5 KB)

Last edited by Alienmario; 07-17-2017 at 08:57.
Alienmario is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 17:42.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode