- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- My apartments & roommates fix mod issues...
- Site Map >
- Modding and Creation >
- Sims 3 Creation >
- Modding Discussion >
- My apartments & roommates fix mod issues...
Posts: 299
Thanks: 1054 in 2 Posts
1. Is the lot an Apartment lot?
2. If it's an apartment lot, is it currently accepting roommates?
I'm trying to add more functionality to my Apartments & Roommates Fix mod, which stops the randomly-created roommates from appearing on Apartment lots, and also allows you to enable and disable roommates at your own choosing.
Right now, I have this:
public static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); }
So, if the lot is an apartment lot, I'm assuming that this is starting my "NewRoommateValidation" -- it does work. I then have NewRoommateValidation determine the amount of rent that is paid.
However, this only works on lots where roommates are currently enabled. So, if the game loads an apartment lot and roommates have not yet been enabled on this lot, it doesn't do anything. (Part of my mod "broke" the rent collection for Apartment lots, I am trying to add that back into the game by having it deduct the funds automatically on a particular day. It DOES work when roommates are Enabled on the lot.)
I'm not sure how to proceed. My NewRoommatesValidation looks like this:
public static void NewRoommateValidation() { if (Household.ActiveHousehold != null && !GameplayMovingModel.MovingCurrentlyInProgress && Household.RoommateManager != null) { RoommateManager.kRoommateRentDay = DaysOfTheWeek.None; Household.RoommateManager.RoommateValidation(); } if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates) { float num2 = Household.RoommateManager.mRoommates.Count + 1; float num3 = Household.RoommateManager.mRoommates.Count / num2; float num4 = RoommateManager.GetRentAmount(Household.ActiveHousehold) * num3; int num5 = (int)(RoommateManager.GetRentAmount(Household.ActiveHousehold) - num4); Household.ActiveHousehold.ModifyFamilyFunds(-num5); StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] { num4 }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format); } else if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot) { int num6 = (RoommateManager.GetRentAmount(Household.ActiveHousehold)); Household.ActiveHousehold.ModifyFamilyFunds(-num6); StyledNotification.Format format2 = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] { num6 }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format2); }
I've added " && Household.RoommateManager.AcceptingRoommates" to the if statement and it doesn't seem to do anything.
Any suggestions for how to proceed with this?
Posts: 299
Thanks: 1054 in 2 Posts
To sum up, I want the game to run a check before loading a lot to see if the lot is currently accepting roommates, and be able to run different things based on that. I already know this will involve OnWorldLoadFinished and OnHouseholdChanged. Perhaps OnPreload would be better than OnWorldLoadFinished??
Posts: 516
Thanks: 4225 in 14 Posts
Posts: 997
Thanks: 22090 in 95 Posts
OnWorldLoadFinished is the right way, but probably won't work when you create
a new game because there's not an active household yet, but I might remember
that wrongly (forgive me JunJayMdM!)
In case I'm right an alarm is the way to go if you are interested to make that check
even when you start a new game (and probably also when you visit the University
world for the first time and you have to choose where your Sims will stay).
To check if the RoommateManager of an Household is accepting roommates,
check the boolean HouseHold.RoommateManager.mAcceptingRoommate.
It's an instance field so you have to reference it with an instance of a HouseHold.
If you are interested in the active household, I think you can use:
Household.ActiveHousehold.RoommateManager.mAcceptingRoommate
(but first check if ActiveHousehold is not null, if it's "associated" with a lot
and if that lot is an Apartment lot, I don't remember the details but I'm
sure you'll figure them out if you already didn't).
For further references, check with ILSpy StartAcceptingRoommates
and StopAcceptingRoommates.
Hope that helps.
Posts: 299
Thanks: 1054 in 2 Posts
I think OnPreload doesn't load Sims at all as it is the time for implementing skill data, do you want the check for active lot or all residential lots? I remember there is a method to run after a household is chosen. |
Just the active lot ... or so I think anyway!
Posts: 299
Thanks: 1054 in 2 Posts
It's been a while and I forgot the little I knew about how the roommates system works. OnWorldLoadFinished is the right way, but probably won't work when you create a new game because there's not an active household yet, but I might remember that wrongly (forgive me JunJayMdM!) In case I'm right an alarm is the way to go if you are interested to make that check even when you start a new game (and probably also when you visit the University world for the first time and you have to choose where your Sims will stay). To check if the RoommateManager of an Household is accepting roommates, check the boolean HouseHold.RoommateManager.mAcceptingRoommate. It's an instance field so you have to reference it with an instance of a HouseHold. If you are interested in the active household, I think you can use: Household.ActiveHousehold.RoommateManager.mAcceptingRoommate (but first check if ActiveHousehold is not null, if it's "associated" with a lot and if that lot is an Apartment lot, I don't remember the details but I'm sure you'll figure them out if you already didn't). For further references, check with ILSpy StartAcceptingRoommates and StopAcceptingRoommates. Hope that helps. |
Okay, I've used Household.RoommateManager.mAcceptingRoommates but it doesn't seem to do anything. I can't find anywhere in ILSpy where it sets it to "true" or "false". I've tried putting "&& Household.RoommateManager.mAcceptingRoommates" in an argument of an if statement, and then else "!Household.RoommateManager.mAcceptingRoommates" but neither seem to have any effect. The first if was called regardless of that being there, and the else never did anything. But I haven't tried it with Household.ActiveHousehold.....etc.
If mAcceptingRoommates is set to true at some point, will it stay that way until it changes to false, even once the game is reloaded?
It doesn't matter at University because it seems to work entirely different there. But I suppose I should check it out. Haven't been to Uni since I started this.
Posts: 997
Thanks: 22090 in 95 Posts
[CUT]mAcceptingRoommate. It's an instance field so you have to reference it with an instance of a HouseHold. |
HouseHold hh = HouseHold.ActiveHousehold; if (hh == null) return; if (hh.RoommateManager == null) return; if (hh.RoommateManager.mAcceptingRoommates == true) ...
To check what methods read or assign the value of that field,
right click on it and then select "Analyze" (with ILSpy).
Posts: 299
Thanks: 1054 in 2 Posts
public static void RoommatesCheck() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.mAcceptingRoommates = true; } else { Household.RoommateManager.mAcceptingRoommates = false; } }
And then I put the true/false in the check of the if statements. Don't have time now to see if it will run.
I already have an alarm that says this:
Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null);
Will it work if I just change it to this:
Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null);
I don't know anything about alarms. But I would guess I need to change the "Household.RoommateManager.mRoommateValidationAlarm" to something else? Not sure what that does.
Posts: 299
Thanks: 1054 in 2 Posts
I just added this:
Code:
public static void RoommatesCheck() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.mAcceptingRoommates = true; } else { Household.RoommateManager.mAcceptingRoommates = false; } } And then I put the true/false in the check of the if statements. Don't have time now to see if it will run. I already have an alarm that says this:
Code:
Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); Will it work if I just change it to this:
Code:
Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); I don't know anything about alarms. But I would guess I need to change the "Household.RoommateManager.mRoommateValidationAlarm" to something else? Not sure what that does. |
I didn't know what to do, so I left it the same and it worked! My household that does NOT have roommates enabled got its rent deducted automatically on time!
My next "issue" is how to create a custom notification message to display with an amount of money.
Posts: 299
Thanks: 1054 in 2 Posts
I didn't know what to do, so I left it the same and it worked! My household that does NOT have roommates enabled got its rent deducted automatically on time! My next "issue" is how to create a custom notification message to display with an amount of money. |
Okay, so it works correctly when roommates are disabled, but now when roommates are enabled, it runs my rent function twice! (happens in "NewRoommateValidation"). here's what I have:
using Sims3.Gameplay; using Sims3.Gameplay.Academics; using Sims3.Gameplay.Actors; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.Autonomy; using Sims3.Gameplay.Careers; using Sims3.Gameplay.CAS; using Sims3.Gameplay.Controllers; using Sims3.Gameplay.Core; using Sims3.Gameplay.EventSystem; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Interfaces; using Sims3.Gameplay.Moving; using Sims3.Gameplay.Objects.Electronics; using Sims3.Gameplay.Objects.Island; using Sims3.Gameplay.RealEstate; using Sims3.Gameplay.Situations; using Sims3.Gameplay.Socializing; using Sims3.Gameplay.StoryProgression; using Sims3.Gameplay.Tutorial; using Sims3.Gameplay.UI; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Visa; using Sims3.SimIFace; using Sims3.SimIFace.CAS; using Sims3.UI; using Sims3.UI.GameEntry; using System; using System.Collections.Generic; namespace LeapsForCauchy { public class RoommatesFix { public static void RoommatesCheck() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.mAcceptingRoommates = true; } else { Household.RoommateManager.mAcceptingRoommates = false; } } public static int GetBillAmount(Household household) { if (household != null) { return (int)((float)-household.LotHome.Cost); } return 0; } public static void NewRoommateValidation() { if (Household.ActiveHousehold != null && !GameplayMovingModel.MovingCurrentlyInProgress && Household.RoommateManager != null) { RoommateManager.kRoommateRentDay = DaysOfTheWeek.None; Household.RoommateManager.RoommateValidation(); } if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates == true) { float num2 = Household.RoommateManager.mRoommates.Count + 1; float num3 = Household.RoommateManager.mRoommates.Count / num2; float num4 = RoommateManager.GetRentAmount(Household.ActiveHousehold) * num3; int num5 = (int)(RoommateManager.GetRentAmount(Household.ActiveHousehold) - num4); Household.ActiveHousehold.ModifyFamilyFunds(-num5); StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] { num4 }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format); } if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates == false) { int num6 = (RoommateManager.GetRentAmount(Household.ActiveHousehold)); Household.ActiveHousehold.ModifyFamilyFunds(-num6); StyledNotification.Format format2 = new StyledNotification.Format("The weekly rent for your hosehold with no roommates has been deducted from your funds.", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format2); } } public class FixedCallToggleRoommateServices : Phone.Call { public class Definition : Phone.Call.CallDefinition<RoommatesFix.FixedCallToggleRoommateServices> { public override string GetInteractionName(ref InteractionInstanceParameters parameters) { string result; if (Household.RoommateManager.AcceptingRoommates) { result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Disable", new object[0]); } else { result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Enable", new object[0]); } return result; } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis }; } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return !isAutonomous && RoommatesFix.ControlRoommateServices(a.Household); } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition(); public override Phone.Call.ConversationBehavior OnCallConnected() { return Phone.Call.ConversationBehavior.TalkBriefly; } public override void OnCallFinished() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.StopAcceptingRoommates(true); } else { Household.RoommateManager.StartAcceptingRoommates(this.Actor.Household); this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[] { new AbsoluteTime(RoommateManager.kRoommateValidationTimeOfDay), RoommateManager.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates }), StyledNotification.NotificationStyle.kGameMessagePositive); Household.RoommateManager.StopAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); } } } public class FixedCallChangeRoommateCount : ImmediateInteraction<Sim, Phone> { public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateCount> { public int mNumRoommates; public Definition() { } public Definition(int num) { this.mNumRoommates = num; } public override string GetInteractionName(ref InteractionInstanceParameters parameters) { return EAText.GetNumberString((double)this.mNumRoommates); } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis }; } public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results) { int num = 8 - actor.Household.NumActorMembersCountingPregnancy + actor.Household.GetNumberOfRoommates(); for (int i = 1; i <= num; i++) { results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateCount.Definition(i), target)); } } public static string TooManyCurrentRoommates() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:TooManyRoommates", new object[0]); } public static string CurrentNumRoommates() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:CurrentNumRoommates", new object[0]); } public static string EnableRoommatesFirst() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]); } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool result; if (!target.IsUsableBy(a)) { result = false; } else if (isAutonomous) { result = false; } else if (!RoommatesFix.ControlRoommateServices(a.Household)) { result = false; } else if (!Household.RoommateManager.AcceptingRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.EnableRoommatesFirst); result = false; } else if (Household.RoommateManager.MaxNumRoommates == this.mNumRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.CurrentNumRoommates); result = false; } else if (this.mNumRoommates < a.Household.GetNumberOfRoommates()) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.TooManyCurrentRoommates); result = false; } else { result = true; } return result; } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition(); public override string GetInteractionName() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis + base.GetInteractionName(); } public override bool RunFromInventory() { return this.Run(); } public override bool Run() { Household.RoommateManager.SetMaxRoommateNumber((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateCount.Definition).mNumRoommates); this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[] { new AbsoluteTime(RoommatesFix.kRoommateValidationTimeOfDay), RoommateManager.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates }), StyledNotification.NotificationStyle.kGameMessagePositive); return true; } } public class FixedCallChangeRoommateType : ImmediateInteraction<Sim, Phone> { public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateType> { public RoommateManager.RoommateTypes mType; public Definition() { } public Definition(RoommateManager.RoommateTypes type) { this.mType = type; } public override string GetInteractionName(ref InteractionInstanceParameters parameters) { return Localization.LocalizeString("Gameplay/Interactions/Roommates:" + this.mType.ToString(), new object[0]); } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis }; } public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results) { results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Female), target)); results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Male), target)); results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Coed), target)); } public static string AlreadyCurrentType() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:AlreadySameType", new object[0]); } public static string EnableRoommatesFirst() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]); } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool result; if (!target.IsUsableBy(a)) { result = false; } else if (isAutonomous) { result = false; } else if (!RoommatesFix.ControlRoommateServices(a.Household)) { result = false; } else if (!Household.RoommateManager.AcceptingRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.EnableRoommatesFirst); result = false; } else if (Household.RoommateManager.RoommateType == this.mType) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.AlreadyCurrentType); result = false; } else { result = true; } return result; } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition(); public override string GetInteractionName() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis + base.GetInteractionName(); } public override bool RunFromInventory() { return this.Run(); } public override bool Run() { Household.RoommateManager.SetRoommateType((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateType.Definition).mType); return true; } } [Tunable] protected static bool kInstantiator; protected static bool kDebugging; public static DaysOfTheWeek kRoommateRentDay = DaysOfTheWeek.Friday; public static float kRoommateRentMultiplier; public static float kRoommateValidationTimeOfDay = 9f; public List<ulong> mRoommates = new List<ulong>(); private int mHouseholdFunds; public static bool ControlRoommateServices(Household household) { return household != null && household.LotHome != null && !household.LotHome.IsDormitoryLot && !GameUtils.IsOnVacation(); } internal static void DebugMsg(string message) { DebugMsg("[DEBUG] RoommatesFix", message); } internal static void DebugMsg(string title, string message) { if (kDebugging) SimpleMessageDialog.Show(title, message); } private static void StoryProgressionRoommatesTweaks() { StoryProgressionService sps = StoryProgressionService.sService; if (sps != null) { ActionTuning at; at = null; at = sps.mDemographicTuning.ActionTuning["AddRoommate"]; if (at != null) at.Multiplier = 0; else DebugMsg("\"AddRoommate\" StoryAction not found"); } else { DebugMsg("StoryProgressionService not instantiated"); } } static RoommatesFix() { RoommatesFix.kRoommateRentMultiplier = 9f; RoommatesFix.kInstantiator = false; LoadSaveManager.ObjectGroupsPreLoad += new ObjectGroupsPreLoadHandler(RoommatesFix.OnPreLoad); World.OnWorldLoadFinishedEventHandler += new EventHandler(RoommatesFix.OnWorldLoadFinished); } public static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); // Household.RoommateManager.StartAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); } // if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) // { // EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(RoommatesFix.OnHouseholdChanged)); // if (Household.ActiveHousehold != null && !GameplayMovingModel.MovingCurrentlyInProgress && Household.RoommateManager != null) // { // RoommateManager.kRoommateRentDay = DaysOfTheWeek.None; // Household.RoommateManager.RoommateValidation(); // } // if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot) // { // int num6 = (RoommateManager.GetRentAmount(Household.ActiveHousehold)); // Household.ActiveHousehold.ModifyFamilyFunds(-num6); // StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] // { // num6 // }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); // StyledNotification.Show(format); // // } { AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(StoryProgressionRoommatesTweaks), "StoryProgressionRoommatesTweaks", AlarmType.NeverPersisted, null); } } //public static ListenerAction OnHouseholdChanged(Event e) //{ // if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates) // { // Household.RoommateManager.StopAcceptingRoommates(false); // return ListenerAction.Keep; // } // else // { // Household.RoommateManager.StopAcceptingRoommates(true); // return ListenerAction.Remove; // } // // } private static void OnPreLoad() { Phone.CallToggleRoommateServices.Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition(); Phone.CallChangeRoommateCount.Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition(); Phone.CallChangeRoommateType.Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition(); } private static void OnHouseholdChanged() { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); // Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); } } } }
Any idea what would cause that to happen twice?
Posts: 299
Thanks: 1054 in 2 Posts
Okay, so it works correctly when roommates are disabled, but now when roommates are enabled, it runs my rent function twice! (happens in "NewRoommateValidation"). here's what I have:
Code:
using Sims3.Gameplay; using Sims3.Gameplay.Academics; using Sims3.Gameplay.Actors; using Sims3.Gameplay.ActorSystems; using Sims3.Gameplay.Autonomy; using Sims3.Gameplay.Careers; using Sims3.Gameplay.CAS; using Sims3.Gameplay.Controllers; using Sims3.Gameplay.Core; using Sims3.Gameplay.EventSystem; using Sims3.Gameplay.Interactions; using Sims3.Gameplay.Interfaces; using Sims3.Gameplay.Moving; using Sims3.Gameplay.Objects.Electronics; using Sims3.Gameplay.Objects.Island; using Sims3.Gameplay.RealEstate; using Sims3.Gameplay.Situations; using Sims3.Gameplay.Socializing; using Sims3.Gameplay.StoryProgression; using Sims3.Gameplay.Tutorial; using Sims3.Gameplay.UI; using Sims3.Gameplay.Utilities; using Sims3.Gameplay.Visa; using Sims3.SimIFace; using Sims3.SimIFace.CAS; using Sims3.UI; using Sims3.UI.GameEntry; using System; using System.Collections.Generic; namespace LeapsForCauchy { public class RoommatesFix { public static void RoommatesCheck() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.mAcceptingRoommates = true; } else { Household.RoommateManager.mAcceptingRoommates = false; } } public static int GetBillAmount(Household household) { if (household != null) { return (int)((float)-household.LotHome.Cost); } return 0; } public static void NewRoommateValidation() { if (Household.ActiveHousehold != null && !GameplayMovingModel.MovingCurrentlyInProgress && Household.RoommateManager != null) { RoommateManager.kRoommateRentDay = DaysOfTheWeek.None; Household.RoommateManager.RoommateValidation(); } if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates == true) { float num2 = Household.RoommateManager.mRoommates.Count + 1; float num3 = Household.RoommateManager.mRoommates.Count / num2; float num4 = RoommateManager.GetRentAmount(Household.ActiveHousehold) * num3; int num5 = (int)(RoommateManager.GetRentAmount(Household.ActiveHousehold) - num4); Household.ActiveHousehold.ModifyFamilyFunds(-num5); StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] { num4 }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format); } if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates == false) { int num6 = (RoommateManager.GetRentAmount(Household.ActiveHousehold)); Household.ActiveHousehold.ModifyFamilyFunds(-num6); StyledNotification.Format format2 = new StyledNotification.Format("The weekly rent for your hosehold with no roommates has been deducted from your funds.", ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); StyledNotification.Show(format2); } } public class FixedCallToggleRoommateServices : Phone.Call { public class Definition : Phone.Call.CallDefinition<RoommatesFix.FixedCallToggleRoommateServices> { public override string GetInteractionName(ref InteractionInstanceParameters parameters) { string result; if (Household.RoommateManager.AcceptingRoommates) { result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Disable", new object[0]); } else { result = Localization.LocalizeString("Gameplay/Interactions/Roommates:Enable", new object[0]); } return result; } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis }; } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { return !isAutonomous && RoommatesFix.ControlRoommateServices(a.Household); } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition(); public override Phone.Call.ConversationBehavior OnCallConnected() { return Phone.Call.ConversationBehavior.TalkBriefly; } public override void OnCallFinished() { if (Household.RoommateManager.AcceptingRoommates) { Household.RoommateManager.StopAcceptingRoommates(true); } else { Household.RoommateManager.StartAcceptingRoommates(this.Actor.Household); this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[] { new AbsoluteTime(RoommateManager.kRoommateValidationTimeOfDay), RoommateManager.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates }), StyledNotification.NotificationStyle.kGameMessagePositive); Household.RoommateManager.StopAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); } } } public class FixedCallChangeRoommateCount : ImmediateInteraction<Sim, Phone> { public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateCount> { public int mNumRoommates; public Definition() { } public Definition(int num) { this.mNumRoommates = num; } public override string GetInteractionName(ref InteractionInstanceParameters parameters) { return EAText.GetNumberString((double)this.mNumRoommates); } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis }; } public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results) { int num = 8 - actor.Household.NumActorMembersCountingPregnancy + actor.Household.GetNumberOfRoommates(); for (int i = 1; i <= num; i++) { results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateCount.Definition(i), target)); } } public static string TooManyCurrentRoommates() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:TooManyRoommates", new object[0]); } public static string CurrentNumRoommates() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:CurrentNumRoommates", new object[0]); } public static string EnableRoommatesFirst() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]); } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool result; if (!target.IsUsableBy(a)) { result = false; } else if (isAutonomous) { result = false; } else if (!RoommatesFix.ControlRoommateServices(a.Household)) { result = false; } else if (!Household.RoommateManager.AcceptingRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.EnableRoommatesFirst); result = false; } else if (Household.RoommateManager.MaxNumRoommates == this.mNumRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.CurrentNumRoommates); result = false; } else if (this.mNumRoommates < a.Household.GetNumberOfRoommates()) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(RoommatesFix.FixedCallChangeRoommateCount.Definition.TooManyCurrentRoommates); result = false; } else { result = true; } return result; } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition(); public override string GetInteractionName() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:MaxNumRoommates", new object[0]) + Localization.Ellipsis + base.GetInteractionName(); } public override bool RunFromInventory() { return this.Run(); } public override bool Run() { Household.RoommateManager.SetMaxRoommateNumber((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateCount.Definition).mNumRoommates); this.Actor.ShowTNSIfSelectable(Localization.LocalizeString("Gameplay/Notifications/Roommates:StartAccepting", new object[] { new AbsoluteTime(RoommatesFix.kRoommateValidationTimeOfDay), RoommateManager.GetRentAmount(this.Actor.Household) * Household.RoommateManager.MaxNumRoommates }), StyledNotification.NotificationStyle.kGameMessagePositive); return true; } } public class FixedCallChangeRoommateType : ImmediateInteraction<Sim, Phone> { public class Definition : ImmediateInteractionDefinition<Sim, Phone, RoommatesFix.FixedCallChangeRoommateType> { public RoommateManager.RoommateTypes mType; public Definition() { } public Definition(RoommateManager.RoommateTypes type) { this.mType = type; } public override string GetInteractionName(ref InteractionInstanceParameters parameters) { return Localization.LocalizeString("Gameplay/Interactions/Roommates:" + this.mType.ToString(), new object[0]); } public override string[] GetPath(bool isFemale) { return new string[] { Localization.LocalizeString("Gameplay/Objects/Electronics/SmartPhone:RealEstateAndTravel", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesPathName", new object[0]) + Localization.Ellipsis, Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis }; } public override void AddInteractions(InteractionObjectPair iop, Sim actor, Phone target, List<InteractionObjectPair> results) { results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Female), target)); results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Male), target)); results.Add(new InteractionObjectPair(new RoommatesFix.FixedCallChangeRoommateType.Definition(RoommateManager.RoommateTypes.Coed), target)); } public static string AlreadyCurrentType() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:AlreadySameType", new object[0]); } public static string EnableRoommatesFirst() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:RoommatesMustBeEnabled", new object[0]); } public override bool Test(Sim a, Phone target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback) { bool result; if (!target.IsUsableBy(a)) { result = false; } else if (isAutonomous) { result = false; } else if (!RoommatesFix.ControlRoommateServices(a.Household)) { result = false; } else if (!Household.RoommateManager.AcceptingRoommates) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.EnableRoommatesFirst); result = false; } else if (Household.RoommateManager.RoommateType == this.mType) { greyedOutTooltipCallback = new GreyedOutTooltipCallback(Phone.CallChangeRoommateType.Definition.AlreadyCurrentType); result = false; } else { result = true; } return result; } } public static InteractionDefinition Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition(); public override string GetInteractionName() { return Localization.LocalizeString("Gameplay/Interactions/Roommates:SetRoommateType", new object[0]) + Localization.Ellipsis + base.GetInteractionName(); } public override bool RunFromInventory() { return this.Run(); } public override bool Run() { Household.RoommateManager.SetRoommateType((base.InteractionDefinition as RoommatesFix.FixedCallChangeRoommateType.Definition).mType); return true; } } [Tunable] protected static bool kInstantiator; protected static bool kDebugging; public static DaysOfTheWeek kRoommateRentDay = DaysOfTheWeek.Friday; public static float kRoommateRentMultiplier; public static float kRoommateValidationTimeOfDay = 9f; public List<ulong> mRoommates = new List<ulong>(); private int mHouseholdFunds; public static bool ControlRoommateServices(Household household) { return household != null && household.LotHome != null && !household.LotHome.IsDormitoryLot && !GameUtils.IsOnVacation(); } internal static void DebugMsg(string message) { DebugMsg("[DEBUG] RoommatesFix", message); } internal static void DebugMsg(string title, string message) { if (kDebugging) SimpleMessageDialog.Show(title, message); } private static void StoryProgressionRoommatesTweaks() { StoryProgressionService sps = StoryProgressionService.sService; if (sps != null) { ActionTuning at; at = null; at = sps.mDemographicTuning.ActionTuning["AddRoommate"]; if (at != null) at.Multiplier = 0; else DebugMsg("\"AddRoommate\" StoryAction not found"); } else { DebugMsg("StoryProgressionService not instantiated"); } } static RoommatesFix() { RoommatesFix.kRoommateRentMultiplier = 9f; RoommatesFix.kInstantiator = false; LoadSaveManager.ObjectGroupsPreLoad += new ObjectGroupsPreLoadHandler(RoommatesFix.OnPreLoad); World.OnWorldLoadFinishedEventHandler += new EventHandler(RoommatesFix.OnWorldLoadFinished); } public static void OnWorldLoadFinished(object sender, EventArgs e) { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); // Household.RoommateManager.StartAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); } // if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) // { // EventTracker.AddListener(EventTypeId.kHouseholdSelected, new ProcessEventDelegate(RoommatesFix.OnHouseholdChanged)); // if (Household.ActiveHousehold != null && !GameplayMovingModel.MovingCurrentlyInProgress && Household.RoommateManager != null) // { // RoommateManager.kRoommateRentDay = DaysOfTheWeek.None; // Household.RoommateManager.RoommateValidation(); // } // if (SimClock.CurrentDayOfWeek == RoommatesFix.kRoommateRentDay && Household.ActiveHouseholdLot.IsApartmentLot) // { // int num6 = (RoommateManager.GetRentAmount(Household.ActiveHousehold)); // Household.ActiveHousehold.ModifyFamilyFunds(-num6); // StyledNotification.Format format = new StyledNotification.Format(Localization.LocalizeString("Gameplay/Interactions/Roommates:RentCollection", new object[] // { // num6 // }), ObjectGuid.InvalidObjectGuid, ObjectGuid.InvalidObjectGuid, StyledNotification.NotificationStyle.kGameMessagePositive); // StyledNotification.Show(format); // // } { AlarmManager.Global.AddAlarm(0.1f, TimeUnit.Seconds, new AlarmTimerCallback(StoryProgressionRoommatesTweaks), "StoryProgressionRoommatesTweaks", AlarmType.NeverPersisted, null); } } //public static ListenerAction OnHouseholdChanged(Event e) //{ // if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot && Household.RoommateManager.AcceptingRoommates) // { // Household.RoommateManager.StopAcceptingRoommates(false); // return ListenerAction.Keep; // } // else // { // Household.RoommateManager.StopAcceptingRoommates(true); // return ListenerAction.Remove; // } // // } private static void OnPreLoad() { Phone.CallToggleRoommateServices.Singleton = new RoommatesFix.FixedCallToggleRoommateServices.Definition(); Phone.CallChangeRoommateCount.Singleton = new RoommatesFix.FixedCallChangeRoommateCount.Definition(); Phone.CallChangeRoommateType.Singleton = new RoommatesFix.FixedCallChangeRoommateType.Definition(); } private static void OnHouseholdChanged() { if (Household.ActiveHousehold != null && Household.ActiveHouseholdLot != null && Household.ActiveHouseholdLot.IsApartmentLot) { Household.RoommateManager.StopAlarm(); Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.NewRoommateValidation), "RoommateValidation", AlarmType.NeverPersisted, null); // Household.RoommateManager.mRoommateValidationAlarm = AlarmManager.Global.AddAlarmDay(RoommatesFix.kRoommateValidationTimeOfDay, DaysOfTheWeek.All, new AlarmTimerCallback(RoommatesFix.RoommatesCheck), "RoommatesCheck", AlarmType.NeverPersisted, null); } } } } Any idea what would cause that to happen twice? |
DUH! Just figured it out! It was because I was calling the alarm handler twice. I rearranged the way some of the stuff works and now it only goes once :-)
This thread makes it look like I'm having a conversation with myself!
Posts: 516
Thanks: 4225 in 14 Posts
Posts: 299
Thanks: 1054 in 2 Posts
Nah, it actually helps you keep track of what you're doing - and keeps you sane as well! |
Except now I feel stupid because since I wrote that I haven't gotten it to work again!! GAH!
Posts: 299
Thanks: 1054 in 2 Posts
I swear it worked! I know it did! Argh!
Any suggestions?
EDIT: It's *finally* working! I had to meddle with the AlarmHandle. I really don't know how it worked the first time, because that code was apparently wrong!
Now, this question still remains: how do I set up a custom notification that will actually display a dollar amount? I am able to get it to display something that I type in manually (not a Localization String), but I can't get it to add the dollar amount to that.
Posts: 516
Thanks: 4225 in 14 Posts
UIUtils.FormatMoney(Your variable name or number)
And just a reminder, if you want to display only numbers (just in case), you need to convert it to string before using it in Localization.
Posts: 299
Thanks: 1054 in 2 Posts
Code:
UIUtils.FormatMoney(Your variable name or number) And just a reminder, if you want to display only numbers (just in case), you need to convert it to string before using it in Localization. |
Okay but I want to include a message with that, something like "Your weekly bills of $xxx have been deducted from your household funds". Will that work in this way?
Posts: 516
Thanks: 4225 in 14 Posts
Posts: 299
Thanks: 1054 in 2 Posts
You should know how to display TNS, I suppose? Include the code as an obeject in the method Localization.LocalizeString(…) and use {0.String} to represent this. |
Okay, yes, but if I write my own message instead of a localized one, how do I insert the amount into that one? Use {0.String} instead?
Posts: 299
Thanks: 1054 in 2 Posts
1. How do I make a TNS with a custom string that will display an amount of a given variable? I am not using a Localization String. yes, I realize it might need to be translated
2. What do I need to do to get an alarm to run a certain number of minutes after World Load Finished/OnHouseholdChange?
My next thing to tackle is another "bug" in EA's roommates system - they really didn't think this through, did they? The way it is set up and with my mod, Roommates work fine if you stay on the same lot. If you change households, they get all screwed up. The state of the roommates from Household A remains the same in Household B. So, for example, if HH A had roommates enabled, and HH B did not, HH B will end up with roommates enabled - the same number that HH A had. And, when RoommateValidation is run, the roommates will be created if they are not part of HH B. Stupid! Also, HH B will still say "Enable Roommate Services" when you check the telephone - even though the game thinks you have them and they have just been added to HH B! If you then Enable and then Disable roommates in HH B to get them to go away, and then switch back to HH A, which originally had roommates enabled, HH A will now be disabled and the people who were living there have been kicked out.
Did that make any sense? Is there any way to fix this? I have implemented "StopAcceptingRoommates" to my new Roommates Validation code, but I am afraid that will kick the roommates out of other households upon switching back. Perhaps it's not possible to do?
Posts: 516
Thanks: 4225 in 14 Posts
StyledNotification.Show(... something I forgot, "The amount of Simoleons: " && UIUtils.FormatMoney(Your variable name or number))
Posts: 299
Thanks: 1054 in 2 Posts
Well, that's even more simple: UIUtils.FormatMoney(Your variable name or number) is apparently a String, I suppose (didn't check). As with how you connect two strings into one, I'll do this: StyledNotification.Show(... something I forgot, "The amount of Simoleons: " && UIUtils.FormatMoney(Your variable name or number)) |
Okay, figured it out! It wasn't quite that, but did involve "+ UITtils.FormatMoney(money) +" in between each custom string.
Now the only thing I need to know is how to get something to run a set number of seconds/minutes after opening a Household and then I can upload the updated mod here on MTS!
Posts: 299
Thanks: 1054 in 2 Posts
But what I really want to try and fix next is what happens when you switch households. And by that I mean, the status of roommates being enabled/disabled when switching households. Right now it seems to be a global status, and not per household.
Is there some way to, for example, have multiple households having multiple different roommates, and the game will remember these roommates attached to each house? From what I've seen, it'll only remember it for one house, and then if you load up another house and want to have roommates, the ones from the previous house will leave when you next go to load that house.
Anyone have any suggestions?
Posts: 299
Thanks: 1054 in 2 Posts
Posts: 997
Thanks: 22090 in 95 Posts
I'm not following the forum much anymore, but I just wanted to warn
you that an instruction I suggested to you in the past is wrong:
DebugMsg(exc.Message + "\n" + exc.StackTrace.Substring(0, 500));
This instruction can throw an exception if the string returned by
StackTrace is shorter than 500 (or whatever value you specify).
Don't use that crappy code as is (it's pretty easy to fix) and sorry.
I've also edited the original post where I suggested that.
Posts: 299
Thanks: 1054 in 2 Posts
Hey pjsutton, I'm not following the forum much anymore, but I just wanted to warn you that an instruction I suggested to you in the past is wrong:
Code:
DebugMsg(exc.Message + "\n" + exc.StackTrace.Substring(0, 500)); This instruction can throw an exception if the string returned by StackTrace is shorter than 500 (or whatever value you specify). Don't use that crappy code as is (it's pretty easy to fix) and sorry. I've also edited the original post where I suggested that. |
I have that in there, but I never see a message so it must "work" the way I want it to, so I can probably just delete it.
The thing I want to do next involves a dictionary (I think) and getting specific info from a certain Lot ID. Here's the link to that discussion:
http://nraas.wikispaces.com/share/v...305903#82856693
Who Posted
|