예제 #1
0
 /// <summary>
 /// Checks if a seller of a house is a player
 /// </summary>
 /// <param name="house">House</param>
 /// <returns>Yes if seller is player, otherwise no</returns>
 private bool IsSellerOfHousePlayer(HouseForSale house)
 {
     if (house.sellerId != -1)
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
        /// <summary>
        /// Generates a random house for sale based on template
        /// </summary>
        /// <returns>Random house for sale</returns>
        private HouseForSale GenerateNonPlayerHouse()
        {
            int position = random.Next(0, randomHouseTemplates.Count);
            RandomHouseTemplate template = randomHouseTemplates.ElementAt(position);
            int          price           = random.Next(template.minPrice, template.maxPrice + 1);
            HouseForSale house           = new HouseForSale(currentEntryId, price, HouseManager.Instance().GetHouseNameForTemplateId(template.templateId), "Los Santos Government", -1, template.templateId);

            currentEntryId++;
            return(house);
        }
예제 #3
0
        /// <summary>
        /// Attemps to purchase a house for character
        /// </summary>
        /// <param name="character">Character</param>
        /// <param name="sellEntryId">Entry id of the house on sale</param>
        /// <param name="nameOfHouse">Name of the house</param>
        public void TryBuyHouseForCharacter(Character character, int sellEntryId, string nameOfHouse)
        {
            if (!entryCheckpoint.IsCharacterInsideCheckpoint(character))
            {
                this.CloseHouseMarketMenuForCharacter(character);
                return;
            }

            HouseForSale house = GetHouseForSaleForEntryId(sellEntryId);

            if (house != HouseForSale.Empty)
            {
                if (character.money >= house.price)
                {
                    HouseManager.Instance().AddHouseOwnershipForCharacter(character, house.templateId, nameOfHouse);
                    character.SetMoney(character.money - house.price);
                    if (IsSellerOfHousePlayer(house))
                    {
                        PlayerManager.Instance().AddMoneyForCharacterWithId(house.sellerId, house.price);
                        if (PlayerManager.Instance().IsCharacterWithIdOnline(house.sellerId))
                        {
                            PlayerManager.Instance().SendNotificationToCharacterWithid(sellEntryId, "Your house " + house.name + " was just sold for " + house.price + "!");
                        }
                    }
                    this.RemoveHouseFromSale(house);
                    this.CloseHouseMarketMenuForCharacter(character);
                    API.shared.playSoundFrontEnd(character.client, "LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS");
                    API.shared.sendNotificationToPlayer(character.client, "Congratulations! You have bought a house at " + HouseManager.Instance().GetBuildingNameForHouseTemplateId(house.templateId) + " for $" + house.price.ToString());
                }
                else
                {
                    API.shared.sendNotificationToPlayer(character.owner.client, "You don't have enought money to buy this property!");
                }
            }
            else
            {
                API.shared.sendNotificationToPlayer(character.client, "Property not found!");
                API.shared.consoleOutput("DEBUG");
                API.shared.consoleOutput("EntryID: " + sellEntryId.ToString());
                foreach (HouseForSale s in housesForSale)
                {
                    API.shared.consoleOutput("ID: " + s.entryId);
                }
            }
        }
예제 #4
0
        /// <summary>
        /// Attemps to purchase a house for character
        /// </summary>
        /// <param name="character">Character</param>
        /// <param name="sellEntryId">Entry id of the house on sale</param>
        /// <param name="nameOfHouse">Name of the house</param>
        public void TryBuyHouseForCharacter(Character character, int sellEntryId, string nameOfHouse)
        {
            if (!entryCheckpoint.IsCharacterInsideCheckpoint(character))
            {
                this.CloseHouseMarketMenuForCharacter(character);
                return;
            }

            HouseForSale house = GetHouseForSaleForEntryId(sellEntryId);

            if (house != HouseForSale.Empty)
            {
                if (character.money >= house.price)
                {
                    HouseManager.Instance().AddHouseOwnershipForCharacter(character, house.templateId, nameOfHouse);
                    character.SetMoney(character.money - house.price);
                    if (IsSellerOfHousePlayer(house))
                    {
                        PlayerManager.Instance().AddMoneyForCharacterWithId(house.sellerId, house.price);
                        if (PlayerManager.Instance().IsCharacterWithIdOnline(house.sellerId))
                        {
                            PlayerManager.Instance().SendNotificationToCharacterWithid(sellEntryId, String.Format("Your house {0} was just sold for {1}!", house.name, house.price));
                        }
                    }
                    this.RemoveHouseFromSale(house);
                    this.CloseHouseMarketMenuForCharacter(character);
                    character.PlayFrontendSound("LOCAL_PLYR_CASH_COUNTER_COMPLETE", "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS");
                    character.SendNotification(String.Format("Congratulations! You have bought a house at {0} for ${1}", HouseManager.Instance().GetBuildingNameForHouseTemplateId(house.templateId), house.price.ToString()));
                }
                else
                {
                    character.SendErrorNotification("You don't have enought money to buy this property!");
                }
            }
            else
            {
                character.SendErrorNotification("Property not found!");
            }
        }
예제 #5
0
        /// <summary>
        /// Refreshes non-player house sell listings
        /// Replaces a random amount of houses on sale, or if not enough, then adds new ones
        /// </summary>
        private void RefreshNonPlayerHouseListings()
        {
            int replaceAmount = random.Next(1, 8);

            for (int i = 0; i < housesForSale.Count; i++)
            {
                HouseForSale house = housesForSale.ElementAt(i);
                if (!IsSellerOfHousePlayer(house))
                {
                    housesForSale.Insert(i, GenerateNonPlayerHouse());
                    replaceAmount--;
                }

                if (replaceAmount == 0)
                {
                    break;
                }
            }

            for (int i = 0; i < replaceAmount; i++)
            {
                housesForSale.Add(GenerateNonPlayerHouse());
            }
        }
예제 #6
0
 /// <summary>
 /// Removes a house that is on sale
 /// </summary>
 /// <param name="house">House</param>
 private void RemoveHouseFromSale(HouseForSale house)
 {
     this.housesForSale.Remove(house);
 }