示例#1
0
        public void RemoveProjban(string regionName, short projId)
        {
            RtRegion rt = GetRtRegionByName(regionName);

            if (rt == null)
            {
                throw new Exception("Invalid region!");
            }
            var p = new Projectile();

            p.SetDefaults(projId);
            if (!rt.ProjectileIsBanned(projId))
            {
                throw new Exception($"{p.name} is not banned in this region.");
            }
            var origin = rt.Projbans;

            if (rt.RemoveBannedProjectile(projId) &&
                _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", rt.Projbans, rt.Id) != 0)
            {
                return;
            }

            rt.Projbans = origin;
            throw new Exception("Database error: No affected rows.");
        }
示例#2
0
        public void AddProjban(string regionName, short projId)
        {
            RtRegion rt = GetRtRegionByName(regionName);

            if (rt == null)
            {
                throw new Exception("Invalid region!");
            }
            var p = new Projectile();

            p.SetDefaults(projId);
            if (rt.ProjectileIsBanned(projId))
            {
                throw new Exception($"{p.name} has been already banned in this region.");
            }

            var modified = new StringBuilder(rt.Projbans);

            if (modified.Length != 0)
            {
                modified.Append(',');
            }
            modified.Append(projId);

            if (_database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", modified, rt.Id) == 0)
            {
                throw new Exception("Database error: No affected rows.");
            }

            rt.Projbans = modified.ToString();
        }
示例#3
0
        public void RemoveProjban(RtRegion rt, short projId)
        {
            if (!rt.ProjectileIsBanned(projId))
            {
                return;
            }

            var origin = rt.Projbans;

            if (rt.RemoveBannedProjectile(projId) &&
                _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", rt.Projbans, rt.Id) != 0)
            {
                return;
            }

            rt.Projbans = origin;
            throw new Exception("Database error: No affected rows.");
        }
示例#4
0
        public void AddProjban(RtRegion rt, short projId)
        {
            if (rt.ProjectileIsBanned(projId))
            {
                return;
            }

            var modified = new StringBuilder(rt.Projbans);

            if (modified.Length != 0)
            {
                modified.Append(',');
            }
            modified.Append(projId);

            _database.Query("UPDATE RtRegions SET Projbans = @0 WHERE Id = @1", modified, rt.Id);

            rt.Projbans = modified.ToString();
        }