Пример #1
0
 public static bool CanVisitHouse(string UserID, House house)
 {
     foreach (string visitor in house.Visitors)
     {
         if (visitor == UserID)
             return true;
     }
     return false;
 }
Пример #2
0
 public static void BroadcastToHouse(House house, string text, string playername)
 {
     foreach (HPlayer player in HousingDistricts.HPlayers)
     {
         if (house.HouseArea.Intersects(new Rectangle(player.TSPlayer.TileX, player.TSPlayer.TileY, 1, 1)))
         {
             player.TSPlayer.SendMessage("<House> <" + playername + ">: " + text, Color.Purple);
         }
     }
 }
Пример #3
0
 public static void BroadcastToHouse(House house, string text, string playername)
 {
     var I = HousingDistricts.HPlayers.Count;
     for (int i = 0; i < I; i++)
     {
         var player = HousingDistricts.HPlayers[i];
         if (house.HouseArea.Intersects(new Rectangle(player.TSPlayer.TileX, player.TSPlayer.TileY, 1, 1)) && !HouseTools.WorldMismatch(house))
             player.TSPlayer.SendMessage("<House> <" + playername + ">: " + text, Color.LightSkyBlue);
     }
 }
Пример #4
0
 public static void BroadcastToHouseOwners(House house, string text)
 {
     foreach (string ID in house.Owners)
     {
         foreach (TSPlayer player in TShock.Players)
         {
             if (player != null)
             {
                 if (player.UserID.ToString() == ID)
                 {
                     player.SendMessage(text, Color.MediumPurple);
                 }
             }
         }
     }
 }
Пример #5
0
 //kinda stupid to pass the house name when the calling method usually has the house object...
 public static bool OwnsHouse(string UserID, House house)
 {
     try
     {
         foreach (string owner in house.Owners)
         {
             if (owner == UserID)
                 return true;
         }
         return false;
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
         return false;
     }
 }
Пример #6
0
 public static bool CanVisitHouse(User U, House house)
 {
     return (U != null && U.ID != 0) && (house.Visitors.Contains(U.ID.ToString()) || house.Owners.Contains(U.ID.ToString()));
 }
Пример #7
0
 public static bool CanVisitHouse(string UserID, House house)
 {
     return (!String.IsNullOrEmpty(UserID) && UserID != "0") && (house.Visitors.Contains(UserID) || house.Owners.Contains(UserID));
 }
Пример #8
0
 public static void BroadcastToHouseOwners(House house, string text)
 {
     foreach (TSPlayer player in TShock.Players)
         if (player != null && player.User != null && house.Owners.Contains(player.User.ID.ToString()))
                 player.SendMessage(text, Color.LightSeaGreen);
 }
Пример #9
0
 public static bool OwnsHouse(string UserID, House house)
 {
     bool isAdmin = false;
     try { isAdmin = TShock.Groups.GetGroupByName(TShock.Users.GetUserByID(Convert.ToInt32(UserID)).Group).HasPermission("house.root"); }
     catch {}
     if (!String.IsNullOrEmpty(UserID) && UserID != "0" && house != null)
     {
         try
         {
             if (house.Owners.Contains(UserID) || isAdmin) return true;
             else return false;
         }
         catch (Exception ex)
         {
             TShock.Log.Error(ex.ToString());
             return false;
         }
     }
     return false;
 }
Пример #10
0
 public static bool WorldMismatch(House house)
 {
     return (house.WorldID != Main.worldID.ToString());
 }
Пример #11
0
 public static bool OwnsHouse(User U, House house)
 {
     if (U == null)
         return false;
     return OwnsHouse(U.ID.ToString(), house);
 }
Пример #12
0
        public static bool ToggleChat(House house, int onOrOff)
        {
            house.ChatEnabled = onOrOff;

            try
            {
                string query = "UPDATE HousingDistrict SET ChatEnabled=@0 WHERE Name=@1";
                TShock.DB.Query(query, house.ChatEnabled.ToString(), house.Name);
            }
            catch (Exception ex)
            {
                TShock.Log.Error(ex.ToString());
                return false;
            }

            return true;
        }
Пример #13
0
        public static bool DeleteVisitor(House house, string id)
        {
            StringBuilder sb = new StringBuilder();
            int count = 0;
            house.Visitors.Remove(id);
            var I = house.Visitors.Count;
            for (int i = 0; i < I; i++)
            {
                var visitor = house.Visitors[i];
                count++;
                sb.Append(visitor);
                if (count != house.Visitors.Count)
                    sb.Append(",");
            }

            try
            {
                string query = "UPDATE HousingDistrict SET Visitors=@0 WHERE Name=@1";

                TShock.DB.Query(query, sb.ToString(), house.Name);
            }
            catch (Exception ex)
            {
                TShock.Log.Error(ex.ToString());
                return false;
            }

            return true;
        }
Пример #14
0
        public static bool ChangeLock(House house)
        {
            bool locked = false;

            if (house.Locked == 0)
                locked = true;
            else
                locked = false;

            house.Locked = locked ? 1 : 0;

            try
            {
                string query = "UPDATE HousingDistrict SET Locked=@0 WHERE Name=@1";

                TShock.DB.Query(query, locked ? 1 : 0, house.Name);
            }
            catch (Exception ex)
            {
                TShock.Log.Error(ex.ToString());
                return false;
            }

            return locked;
        }
Пример #15
0
        public static bool ToggleChat(House house, int onOrOff)
        {
            house.ChatEnabled = onOrOff;

            List<SqlValue> values = new List<SqlValue>();
            values.Add(new SqlValue("ChatEnabled", "'" + house.ChatEnabled.ToString() + "'"));

            List<SqlValue> wheres = new List<SqlValue>();
            wheres.Add(new SqlValue("Name", "'" + house.Name + "'"));

            HousingDistricts.SQLEditor.UpdateValues("HousingDistrict", values, wheres);
            return true;
        }
Пример #16
0
        public static bool AddNewVisitor(House house, string id)
        {
            StringBuilder sb = new StringBuilder();
            int count = 0;
            house.Visitors.Add(id);
            foreach (string visitor in house.Visitors)
            {
                count++;
                sb.Append(visitor);
                if (count != house.Visitors.Count)
                    sb.Append(",");
            }
            List<SqlValue> values = new List<SqlValue>();
            values.Add(new SqlValue("Visitors", "'" + sb.ToString() + "'"));

            List<SqlValue> wheres = new List<SqlValue>();
            wheres.Add(new SqlValue("Name", "'" + house.Name + "'"));

            HousingDistricts.SQLEditor.UpdateValues("HousingDistrict", values, wheres);
            return true;
        }