public void Execute(IRocketPlayer caller, string[] command)
        {
            UnturnedPlayer player = (UnturnedPlayer)caller;
            OwnerItem      bfound = null;
            HouseItem      afound = null;

            try
            {
                bfound = Plugin.Instance.Configuration.Instance.BoughtHouses.Find(c => (c.house == Plugin.Instance.getHouse(player.Position).position));
                afound = Plugin.Instance.Configuration.Instance.Houses.Find(c => (c.id == Plugin.Instance.getHouseLevelObject(player.Position).id));
            }
            catch { if (afound != null)
                    {
                        UnturnedChat.Say(player, "This house is not calimed and cost " + afound.cost + "!", Color.red); return;
                    }
                    UnturnedChat.Say(player, "Couden't manage to find a house here!", Color.red); return; }
            string final = "";

            if (bfound == null && afound != null)
            {
                final = "This house is not calimed and cost " + afound.cost + "!";
            }
            else if (bfound != null)
            {
                final = "This house has been claimed by " + Edsparr.DisplaynameSaver.Plugin.Instance.GetDisplayName((CSteamID)bfound.owner) + " and payed the rent at " + bfound.boughtAt + " of " + afound.cost + "!";
            }
            else
            {
                UnturnedChat.Say(player, "House not found!", Color.red);
                return;
            }
            UnturnedChat.Say(player, final, Color.yellow);
        }
示例#2
0
 public bool IsInHouse(Transform house, out OwnerItem houseee)
 {
     houseee = null;
     if (house == null)
     {
         return(false);
     }
     foreach (var item in Configuration.Instance.Houses)
     {
         var housee = getHouseLevelObject(house.position);
         if (housee != null && Configuration.Instance.BoughtHouses.Find(c => (c.house == getHouse(housee.transform.position).position)) != null)
         {
             houseee = Configuration.Instance.BoughtHouses.Find(c => (c.house == getHouse(housee.transform.position).position)); return(true);
         }
     }
     return(false);
 }
示例#3
0
        public void Update()
        {
            if (!Level.isLoaded)
            {
                return;
            }
            if (DateTime.Now > n.AddSeconds(1))
            {
                n = DateTime.Now;
                foreach (var item in Configuration.Instance.BoughtHouses)
                {
                    if (DateTime.Now > item.boughtAt.AddHours(Configuration.Instance.FeeTime))
                    {
                        if (getCost(getHouse(item.house)) > Uconomy.Instance.Database.GetBalance(item.owner.ToString()))
                        {
                            clearHouse(getHouse(item.house)); continue;
                        }
                        Uconomy.Instance.Database.IncreaseBalance(item.owner.ToString(), -getCost(getHouse(item.house)));
                    }
                }
                List <BarricadeData> barricades = new List <BarricadeData>();
                List <StructureData> structures = new List <StructureData>();
                foreach (var region in BarricadeManager.regions)
                {
                    foreach (var data in region.barricades)
                    {
                        if (data.barricade.isDead)
                        {
                            continue;
                        }
                        OwnerItem house = null;
                        bool      IsInH = IsInHouse(getTransform(data.point), out house);
                        if (!IsInH || house != null && IsInH && data.group != house.steamGroup && data.owner != house.owner && data.group != 0)
                        {
                            barricades.Add(data);
                        }
                    }
                }

                foreach (var region in StructureManager.regions)
                {
                    foreach (var data in region.structures)
                    {
                        if (data.structure.isDead)
                        {
                            continue;
                        }
                        OwnerItem house = null;
                        bool      IsInH = IsInHouse(getTransform(data.point), out house);
                        if (!IsInH || house != null && data.group != house.steamGroup && data.owner != house.owner && data.group != 0)
                        {
                            structures.Add(data);
                        }
                    }
                }
                foreach (var s in structures)
                {
                    UnturnedPlayer placer = UnturnedPlayer.FromCSteamID((CSteamID)s.owner);
                    if (placer != null)
                    {
                        try
                        {
                            UnturnedChat.Say(placer, "You're not allowed to place structures outside your house!", Color.red);
                        }catch { }
                        placer.GiveItem(s.structure.id, 1);
                    }
                    var rocket = new RocketPlayer(s.owner.ToString());
                    if (!rocket.HasPermission("houseplugin.bypass"))
                    {
                        DeleteStructure(getTransform(s.point));
                    }
                }
                foreach (var b in barricades)
                {
                    UnturnedPlayer placer = UnturnedPlayer.FromCSteamID((CSteamID)b.owner);
                    if (placer != null)
                    {
                        try
                        {
                            UnturnedChat.Say(placer, "You're not allowed to place barricades outside your house!", Color.red);
                        }catch { }
                        placer.GiveItem(b.barricade.id, 1);
                    }
                    var rocket = new RocketPlayer(b.owner.ToString());
                    if (!rocket.HasPermission("houseplugin.bypass"))
                    {
                        DeleteBarriacade(getTransform(b.point));
                    }
                }
            }
        }