Example #1
0
        /// <summary>
        /// Initializes all event handlers
        /// Add all event handlers here
        /// </summary>
        private void InitEvents()
        {
            // TODO: change to use character
            RegisterEvent("EVENT_REQUEST_ENTER_HOUSE", HouseManager.Instance(), "RequestEnterHouse");
            RegisterEvent("EVENT_REQUEST_EXIT_HOUSE", HouseManager.Instance(), "RequestExitHouse");
            RegisterEvent("EVENT_REQUEST_CREATE_ACCOUNT", PlayerManager.Instance(), "RequestCreateAccount");
            RegisterEvent("EVENT_REQUEST_SELECT_CHARACTER", PlayerManager.Instance(), "RequestSelectCharacter");
            RegisterEvent("EVENT_REQUEST_CREATE_CHARACTER_MENU", PlayerManager.Instance(), "RequestCreateCharacterMenu");
            RegisterEvent("EVENT_REQUEST_CREATE_CHARACTER", PlayerManager.Instance(), "RequestCreateCharacter");
            RegisterEvent("EVENT_REQUEST_OWNED_HOUSES", HouseManager.Instance(), "SendListOfOwnedHousesToClient");
            RegisterEvent("EVENT_SET_PLAYER_USING_PHONE", PlayerManager.Instance(), "SetPlayerUsingPhone");
            RegisterEvent("EVENT_SET_PLAYER_NOT_USING_PHONE", PlayerManager.Instance(), "SetPlayerPhoneOut");
            RegisterEvent("EVENT_SEND_TEXT_MESSAGE", PlayerManager.Instance(), "TrySendTextMessage");
            RegisterEvent("EVENT_ADD_PHONE_CONTACT", PlayerManager.Instance(), "TryAddNewContact");
            RegisterEvent("EVENT_REMOVE_PHONE_CONTACT", PlayerManager.Instance(), "TryDeleteContact");
            RegisterEvent("EVENT_REMOVE_TEXT_MESSAGE", PlayerManager.Instance(), "TryDeleteTextMessage");
            RegisterEvent("EVENT_START_PHONE_CALL", PlayerManager.Instance(), "TryStartPhoneCall");
            RegisterEvent("EVENT_ACCEPT_PHONE_CALL", PlayerManager.Instance(), "TryAcceptPhoneCall");
            RegisterEvent("EVENT_END_PHONE_CALL", PlayerManager.Instance(), "TryHangupPhoneCall");
            RegisterEvent("EVENT_EXIT_VEHICLE_SHOP", VehicleManager.Instance(), "TryExitVehicleShop");
            RegisterEvent("EVENT_BUY_VEHICLE", VehicleManager.Instance(), "TryPurchaseVehicle");
            RegisterEvent("EVENT_TRY_SPAWN_VEHICLE", VehicleManager.Instance(), "SpawnVehicleForCharacter");
            RegisterEvent("EVENT_TRY_PARK_VEHICLE", VehicleManager.Instance(), "ParkVehicle");
            RegisterEvent("EVENT_TRY_LOCK_VEHICLE", VehicleManager.Instance(), "LockVehicleWithId");
            RegisterEvent("EVENT_TRY_BUY_PARKING_SPOT", VehicleManager.Instance(), "TryPurchasePark");
            RegisterEvent("EVENT_TRY_SET_SPAWN_LOCATION", PlayerManager.Instance(), "SetCharacterSpawnHouse");
            RegisterEvent("EVENT_ACCEPT_JOB", JobManager.Instance(), "TakeJobForClient", Option.OPTION_USES_CHARACTER);
            RegisterEvent("EVENT_TRY_BUY_PROPERTY", HouseManager.Instance(), "TryBuyMarketHouseForCharacter", Option.OPTION_USES_CHARACTER);
            RegisterEvent("EVENT_TRY_USE_ITEM", ItemManager.Instance(), "TryUseItemForCharacter", Option.OPTION_USES_CHARACTER);
            RegisterEvent("EVENT_TRY_BUY_ITEM", ItemManager.Instance(), "TryBuyItemForCharacter", Option.OPTION_USES_CHARACTER);
            RegisterEvent("EVENT_TRY_SELL_ITEM", ItemManager.Instance(), "TrySellItemForCharacter", Option.OPTION_USES_CHARACTER);

            /// Faction events
            RegisterEvent("EVENT_ARREST_CHARACTER", FactionManager.Instance().LawEnforcement(), "ArrestCharacter", Option.OPTION_USES_CHARACTER);
        }
Example #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);
        }
Example #3
0
        /// <summary>
        /// Gets names of buildings for houses on sale
        /// </summary>
        /// <param name="housesForSale"></param>
        /// <returns>List of building names</returns>
        private List <string> GetBuildingNamesForHousesOnSale(List <HouseForSale> housesForSale)
        {
            List <string> buildingNames = new List <string>();

            foreach (HouseForSale house in housesForSale)
            {
                buildingNames.Add(HouseManager.Instance().GetBuildingNameForHouseTemplateId(house.templateId));
            }
            return(buildingNames);
        }
Example #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, "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);
                }
            }
        }
Example #5
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!");
            }
        }