#### Ryoshu

Level 2
ok I am trying to make a gold system where every 30 seconds you gain 5 gold. along with this with every farm you build. every time u gain gold from that 30 second period each farm increases it by 3 gold. can someone explain to me how I can make this work? ive been trying this out for hours and I cant get it to work. perhaps im not understanding something

#### Dr Super Good

Spell Reviewer
Level 62
Your wording is a bit confusing...
Do you mean...
Each time income happens, income increases by 3 times the number of farms.
Each farm increases income by 3.

Both require you to keep track of the number of farms. It is advisable to use an integer variable for this instead of counting the units of a type. Building farms increments the variable. Farms that die decrements the variable. If there are many players with separate incomes you need to use an integer array where the array index is the player slot number.

Each time income happens, income increases by 3 times the number of farms.
You need an integer variable to keep track of current income. Then do the folowing pesudo code.
income = income + 3 * farms

You need to set income to 5 at map initialization. You will also need to make income an array if multiple players have separate income and the index used is the player slot number who's income is being processed.

Each farm increases income by 3.
Much simpler than above.
add 5 + 3 * farms to player's gold

If income is separate for many players then you will need to loop through all players with income every income period and do the income for them one at a time. Use player slot number as the index for any arrays.

The income period can be done via a timer with a timer window (for ingame visuals) or even a perodic trigger set to fire every 30 seconds.

#### defskull

Level 33
Try my Income Generator in my Signature.

#### Starquizer

Level 16
Try this
• Ore Gen Fixed Time
• Events
• Time - Every 30.00 seconds of game time
• Conditions
• Actions
• For each (Integer A) from 1 to MaxPlayers, do (Actions)
• Loop - Actions
• Set loopingPlayer = (Player((Integer A)))
• Custom script: set bj_wantDestroyGroup = true
• Set NumOfMinesOwned[(Integer A)] = (Number of living OreMine units owned by loopingPlayer)
• Set VariableValue = (NumOfMinesOwned[(Integer A)] x ValuePerDuration)
• Player - Add (FixedValue + VariableValue) to loopingPlayer Current gold

Last edited: