Exemple #1
0
        private void ParseInfoKeyString(Player player, String s)
        {
            String[] infoKeyTokens = s.Split('\\');

            for (int i = 0; i < infoKeyTokens.Length; i += 2)
            {
                if (i + 1 >= infoKeyTokens.Length)
                {
                    // Must be an odd number of strings - a key without a value - ignore it.
                    break;
                }

                String key   = infoKeyTokens[i];
                String value = infoKeyTokens[i + 1];

                // find or create InfoKey object
                InfoKey infoKey = Common.FirstOrDefault <InfoKey>(player.InfoKeys, ik => ik.Key == key);

                if (infoKey == null)
                {
                    infoKey     = new InfoKey();
                    infoKey.Key = key;

                    // add new infokey
                    player.InfoKeys.Add(infoKey);
                }
                else
                {
                    // don't create a new value entry if the previous value is exactly the same
                    if (infoKey.NewestValueValue == value)
                    {
                        continue;
                    }
                }

                // create infokey value
                InfoKeyValue infoKeyValue = new InfoKeyValue();
                infoKeyValue.Value     = value;
                infoKeyValue.Timestamp = currentTimestamp;

                // add new value to infokey values
                infoKey.Values.Add(infoKeyValue);
            }

            // create a Steam ID key if the player isn't a HLTV proxy.
            InfoKey hltv = Common.FirstOrDefault(player.InfoKeys, ik => ik.Key == "*hltv");
            InfoKey sid  = Common.FirstOrDefault(player.InfoKeys, ik => ik.Key == "*sid");

            if (hltv == null && sid != null)
            {
                String steamId = Common.CalculateSteamId(sid.NewestValueValue);

                if (steamId != null)
                {
                    AddInfoKey(player, "SteamId", steamId);
                }
            }
        }
Exemple #2
0
        private void AddInfoKey(Player player, String key, String value)
        {
            InfoKey targetInfoKey = Common.FirstOrDefault <InfoKey>(player.InfoKeys, ik => ik.Key == key);

            if (targetInfoKey == null)
            {
                targetInfoKey     = new InfoKey();
                targetInfoKey.Key = key;
                player.InfoKeys.Add(targetInfoKey);
            }

            if (targetInfoKey.NewestValueValue != value)
            {
                InfoKeyValue ikv = new InfoKeyValue();
                ikv.Value     = value;
                ikv.Timestamp = currentTimestamp;
                targetInfoKey.Values.Add(ikv);
            }
        }
        private void ParseInfoKeyString(Player player, String s)
        {
            String[] infoKeyTokens = s.Split('\\');

            for (int i = 0; i < infoKeyTokens.Length; i += 2)
            {
                if (i + 1 >= infoKeyTokens.Length)
                {
                    // Must be an odd number of strings - a key without a value - ignore it.
                    break;
                }

                String key = infoKeyTokens[i];
                String value = infoKeyTokens[i + 1];

                // find or create InfoKey object
                InfoKey infoKey = Common.FirstOrDefault<InfoKey>(player.InfoKeys, ik => ik.Key == key);

                if (infoKey == null)
                {
                    infoKey = new InfoKey();
                    infoKey.Key = key;

                    // add new infokey
                    player.InfoKeys.Add(infoKey);
                }
                else
                {
                    // don't create a new value entry if the previous value is exactly the same
                    if (infoKey.NewestValueValue == value)
                    {
                        continue;
                    }
                }

                // create infokey value
                InfoKeyValue infoKeyValue = new InfoKeyValue();
                infoKeyValue.Value = value;
                infoKeyValue.Timestamp = currentTimestamp;

                // add new value to infokey values
                infoKey.Values.Add(infoKeyValue);
            }

            // create a Steam ID key if the player isn't a HLTV proxy.
            InfoKey hltv = Common.FirstOrDefault(player.InfoKeys, ik => ik.Key == "*hltv");
            InfoKey sid = Common.FirstOrDefault(player.InfoKeys, ik => ik.Key == "*sid");

            if (hltv == null && sid != null)
            {
                String steamId = Common.CalculateSteamId(sid.NewestValueValue);

                if (steamId != null)
                {
                    AddInfoKey(player, "SteamId", steamId);
                }
            }
        }
        private void AddInfoKey(Player player, String key, String value)
        {
            InfoKey targetInfoKey = Common.FirstOrDefault<InfoKey>(player.InfoKeys, ik => ik.Key == key);

            if (targetInfoKey == null)
            {
                targetInfoKey = new InfoKey();
                targetInfoKey.Key = key;
                player.InfoKeys.Add(targetInfoKey);
            }

            if (targetInfoKey.NewestValueValue != value)
            {
                InfoKeyValue ikv = new InfoKeyValue();
                ikv.Value = value;
                ikv.Timestamp = currentTimestamp;
                targetInfoKey.Values.Add(ikv);
            }
        }