public static void setImmune(this Entity entity, bool state, DGAdmin.GroupsDatabase database)
 {
     DGAdmin.PlayerInfo playerFromImmunes = database.FindMatchingPlayerFromImmunes(entity.GetInfo());
     if (playerFromImmunes == null && state)
     {
         database.ImmunePlayers.Add(entity.GetInfo());
     }
     if (playerFromImmunes != null && !state)
     {
         database.ImmunePlayers.Remove(playerFromImmunes);
     }
     return;
 }
Exemple #2
0
        //CHANGE
        public static bool FixPlayerIdentifiers(this Entity player, DGAdmin.GroupsDatabase database)
        {
            player.setLogged(false);
            var matchedplayerinfo = database.FindEntryFromPlayersOR(player.GetInfo());

            if (matchedplayerinfo != null)
            {
                database.Players.Remove(matchedplayerinfo.Value.Key);
                database.Players[DGAdmin.PlayerInfo.CommonIdentifiers(player.GetInfo(), matchedplayerinfo.Value.Key)] = matchedplayerinfo.Value.Value;
                return(true);
            }
            return(false);
        }
        public static DGAdmin.GroupsDatabase.Group GetGroup(this Entity entity, DGAdmin.GroupsDatabase database)
        {
            KeyValuePair <DGAdmin.PlayerInfo, string>?playerFromGroups = database.FindEntryFromPlayersAND(entity.GetInfo());

            if (playerFromGroups == null)
            {
                return(database.GetGroup("default"));
            }
            DGAdmin.GroupsDatabase.Group grp = database.GetGroup(playerFromGroups.Value.Value);
            if (grp != null)
            {
                return(grp);
            }
            else
            {
                DGAdmin.WriteLog.Error("# Player " + entity.Name + ": GUID=" + entity.GUID + ", HWID = " + entity.GetHWID().ToString());
                DGAdmin.WriteLog.Error("# Is in nonexistent group: " + playerFromGroups);
                return(database.GetGroup("default"));
            }
        }
        public static string GetFormattedName(this Entity player, DGAdmin.GroupsDatabase database)
        {
            DGAdmin.GroupsDatabase.Group grp = player.GetGroup(database);
            var alias = "";

            if (DGAdmin.ChatAlias.Keys.Contains(player.GUID))
            {
                alias = DGAdmin.ChatAlias[player.GUID];
            }
            if (!string.IsNullOrWhiteSpace(grp.short_name))
            {
                return(DGAdmin.Lang_GetString("FormattedNameRank").Format(new Dictionary <string, string>()
                {
                    { "<shortrank>", grp.short_name },
                    { "<rankname>", grp.group_name },
                    { "<name>", (alias != "")?alias : player.Name },
                }));
            }
            return(DGAdmin.Lang_GetString("FormattedNameRankless").Format(new Dictionary <string, string>()
            {
                { "<name>", (alias != "")?alias : player.Name },
            }));
        }
 public static bool HasPermission(this Entity player, string permission_string, DGAdmin.GroupsDatabase database)
 {
     if (DGAdmin.ConfigValues.DEBUG && DGAdmin.ConfigValues.DEBUGOPT.PERMSFORALL)
     {
         return(true);
     }
     return(database.GetEntityPermission(player, permission_string));
 }
 public static bool isImmune(this Entity entity, DGAdmin.GroupsDatabase database)
 {
     return(database.FindMatchingPlayerFromImmunes(entity.GetInfo()) != null);
 }