Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[C#] ID to Hashtag converter method

Custom Title Activated
Loyal Member
Joined
Jun 30, 2008
Messages
3,451
Reaction score
1,616
PHP:
        private static readonly char[] SEARCH_TAG_CHARS = "0289PYLQGRJCUV".ToCharArray();
        public static string GetHashtagFromId(long id)
        {
            if (GetHighInt(id) <= 255)
            {
                StringBuilder sb = new StringBuilder();
                int cnt = 11;
                int ccnt = Constants.SEARCH_TAG_CHARS.Length;
                id = ((long)GetLowInt(id) << 8) + (GetHighInt(id));
                do
                {
                    sb.Append(Constants.SEARCH_TAG_CHARS[(int)(id % ccnt)]);
                    id /= ccnt;
                    if (id <= 0)
                    {
                        break;
                    }
                } while (++cnt > 0);
                sb.Append("#");

                return new string(sb.ToString().Reverse().ToArray());
            }
            return "";
        }


        public static int GetLowInt(long l)
        {
            return (int)(l & 0xFFFFFFFF);
        }

        public static int GetHighInt(long l)
        {
            return (int)(l >> 32);
        }

This is how Clash of Clans creates their hashtags. Enjoy.
 
Last edited:
Back
Top