Giving money each ingame month


#1

Hello, here I am again. I have found some time to log in and practice code. As I have been coding my mod, i was wondering how to make a function to give each month a ‘x’ value of money to the company. @Mabb had shown me how to do this some months ago with this piece of code.

var handler = function (e) {
    GameManager.company.adjustCash(1000, "test");
};

GDT.on(GDT.eventKeys.gameplay.weekProceeded, handler);

EDIT: It now works. It gives 1K each week.


#2

I came up with a newer solution, nevermind. This one gives money each week. I’m gonna modify it so it’s gonna use months instead. I have updated the main post with the new code.


#3

The way I did it is this:

function a() {
  gcgd = GameManager.company.getDate(GameManager.company.currentWeek);
  if (gcgd.week == 1) {
             // your code
  }
}
    
GDT.on(GDT.eventKeys.gameplay.weekProceeded, a);

The game checks whether the week number is 1 each time the week proceeds, and since there is only one week 1 every month, it will execute only then.

This may not be the best method on doing it, but it’s the way I’ve done it multiple times and it does actually work.


#4

Sure, I’ll try to use that later. Thanks for telling me.


#5
GDT.on(GDT.eventKeys.gameplay.weekProceeded, (function(){
if (GameManager.company.currentWeek % 4 == 0)
{
 //your fancy code
}
}));

pseudo:
when weekProceeded is triggered do
if total weeks can be divided by four then
//your code

This should work… I think.


#6

Yeah obviously.


#7

Where do i paste the “code” that you wrote?i wanna test it myself