Esempio n. 1
0
        public void UpdateRegisteredPlayersRanks(string newName)
        {
            foreach (var player in PlayerAccountModule.PlayersAccounts)
            {
                player.Rank = newName;
                PlayerAccountModule.UpdatePlayerAccount(player);
                //Log.Info($"Binding ranks to {player.}'s session (Expires when server restarts)");
                RankData MainRank = GetRankData(PlayerAccountModule.GetRank(player.SteamID));
                if (!PlayersInheritedRanksStore.ContainsKey(player.SteamID))
                {
                    List <RankData> ListRanks = new List <RankData>();
                    PlayersInheritedRanksStore.Add(player.SteamID, ListRanks);
                    foreach (var InheritedRank in MainRank.Inherits)
                    {
                        RankData rankData = GetRankData(InheritedRank);
                        PlayersInheritedRanksStore[player.SteamID].Add(rankData);
                        GetInheritedRanks(rankData, player.SteamID);
                    }
                }
                //Only Re-apply users rank if perm override is enabled.
                if (EssentialsPlugin.Instance.Config.OverrideVanillaPerms)
                {
                    MySession.Static.SetUserPromoteLevel(player.SteamID, ParseMyPromoteLevel(MainRank.KeenLevelRank));
                }

                string Ranks = ($"{MainRank.RankName},");
                foreach (RankData inherited in PlayersInheritedRanksStore[player.SteamID])
                {
                    Ranks += ($"{inherited.RankName},");
                }
                Ranks = Ranks.TrimEnd(',');
                //Log.Info($"The following ranks have been assiged to {player.Name}: {Ranks}");
            }
        }
Esempio n. 2
0
        public static void InsertDiscord(ulong steamID, string discordID, string discordName, Dictionary <ulong, string> RoleData)
        {
            if (steamID == 0)
            {
                Log.Info($"Cannont Insert Discord, SteamId is 0");
                return;
            }

            Log.Info($"DiscordID for {steamID} received from SEDB!... Inserting into player account ({discordID})");
            var AccModule = new PlayerAccountModule();
            var account   = AccModule.GetAccount(steamID);

            account.DiscordData.DiscordID   = ulong.Parse(discordID);
            account.DiscordData.DiscordName = discordName;
            foreach (var role in RoleData)
            {
                if (account.DiscordData.DiscordID == ulong.Parse(discordID))
                {
                    account.DiscordData.DiscordName = discordName;
                    if (!account.DiscordData.Roles.ContainsKey(role.Key))
                    {
                        account.DiscordData.Roles.Add(role.Key, role.Value);
                    }
                }
            }

            AccModule.UpdatePlayerAccount(account);
        }