Hi there! You are currently browsing as a guest. Why not create an account? Then you get less ads, can thank creators, post feedback, keep a list of your favourites, and more!
Field Researcher
Original Poster
#1 Old 20th Jun 2015 at 2:23 AM Last edited by pjsutton : 22nd Jun 2015 at 5:16 PM.
Default My apartments & roommates fix mod issues...
I'm having trouble getting something to work. Basically, upon loading the game, I want it to check the following things:

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:



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:



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?
Advertisement
Field Researcher
Original Poster
#2 Old 20th Jun 2015 at 6:33 AM Last edited by pjsutton : 20th Jun 2015 at 6:46 AM.
I just realized I would run this as an alarm, and I think I can figure that out ... but I'm still stumped with how to check if the lot is getting roommates or not.

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??
Instructor
#3 Old 20th Jun 2015 at 4:01 PM
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.
Inventor
#4 Old 20th Jun 2015 at 4:37 PM
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.
Field Researcher
Original Poster
#5 Old 20th Jun 2015 at 7:06 PM
Quote: Originally posted by SimsMatthew
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!
Field Researcher
Original Poster
#6 Old 20th Jun 2015 at 7:15 PM
Quote: Originally posted by Arsil
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.
Inventor
#7 Old 20th Jun 2015 at 7:34 PM
Quote: Originally posted by Arsil
[CUT]mAcceptingRoommate.
It's an instance field so you have to reference it with an instance of a HouseHold.


Code:
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).
Field Researcher
Original Poster
#8 Old 20th Jun 2015 at 7:38 PM
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:



Will it work if I just change it to this:



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.
Field Researcher
Original Poster
#9 Old 20th Jun 2015 at 10:49 PM
Quote: Originally posted by pjsutton
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:



Will it work if I just change it to this:



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.
Field Researcher
Original Poster
#10 Old 20th Jun 2015 at 11:29 PM
Quote: Originally posted by pjsutton
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:



Any idea what would cause that to happen twice?
Field Researcher
Original Poster
#11 Old 21st Jun 2015 at 3:24 AM
Quote: Originally posted by pjsutton
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:



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!
Instructor
#12 Old 21st Jun 2015 at 4:40 AM
Nah, it actually helps you keep track of what you're doing - and keeps you sane as well!
Field Researcher
Original Poster
#13 Old 21st Jun 2015 at 4:45 AM
Quote: Originally posted by SimsMatthew
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!
Field Researcher
Original Poster
#14 Old 21st Jun 2015 at 6:19 AM Last edited by pjsutton : 21st Jun 2015 at 7:24 AM.
I have been trying for 3 hours to replicate the result I got in post #9 using the code I posted in #10 and cannot for the life of me get it to work again!!! I guess it's time to call it a night...

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.
Instructor
#15 Old 21st Jun 2015 at 12:35 PM
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.
Field Researcher
Original Poster
#16 Old 21st Jun 2015 at 2:48 PM
Quote: Originally posted by SimsMatthew
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?
Instructor
#17 Old 21st Jun 2015 at 3:25 PM
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.
Field Researcher
Original Poster
#18 Old 21st Jun 2015 at 7:34 PM
Quote: Originally posted by SimsMatthew
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?
Field Researcher
Original Poster
#19 Old 22nd Jun 2015 at 7:03 AM
Current questions:

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?
Instructor
#20 Old 22nd Jun 2015 at 12:03 PM
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))
Field Researcher
Original Poster
#21 Old 22nd Jun 2015 at 4:58 PM
Quote: Originally posted by SimsMatthew
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!
Field Researcher
Original Poster
#22 Old 25th Jun 2015 at 6:32 AM
If anyone is still reading this, I posted the updated mod.

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?
Field Researcher
Original Poster
#23 Old 15th Jul 2015 at 5:12 AM
I'm going to attempt to make the roommates status persistable. Icaurs gave me some ideas on the Nraas forum, but I am trying to figure out where to start! Afraid of "breaking" what I already have!
Inventor
#24 Old 16th Jul 2015 at 11:03 AM
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.
Field Researcher
Original Poster
#25 Old 16th Jul 2015 at 8:40 PM
Quote: Originally posted by Arsil
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
Page 1 of 3
Back to top