Quote:
Originally Posted by 11530
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])*2 + 60265728 + AuthID[8]-48;
new iDiv = iFriendID/100000000;
new iIdx = 9-(iDiv?iDiv/10+1?0);
iUpper += iDiv;
IntToString(iFriendID, FriendID[iIdx], size-iIdx);
iIdx = FriendID[9];
IntToString(iUpper, FriendID, size);
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
__________________