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
add income to player's gold
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.