For even higher efficency and easier use.
Every time a building is made, you add the amount of gold to a integer array of level of the building player and every 10 seconds you loop through the array and add the gold in each level to the corrosponding player. And when the unit dies, you simply remove the quantity from the integer for the owning player. This saves you from looping through all the buildings and checking if everyone is allive and then adding the gold for the player making it demmand a lot fewer recources (processing power) to run and so will be more efficent.
I use the above system when ever possiable since it is also easier to program for multiple buildings.