# [Trigger]Income Triggers

Status
Not open for further replies.

#### Bwathke

Level 9
How do I do the income? Like what is the triggers? I couldn't find a tut for it.

#### Pharaoh_

Level 40
You mean like
• Income
• Events
• Time - Every 5.00 seconds of game-time
• Conditions
• Actions
• For each (Integer A) from 1 to 12, (do Actions)
• Loop - Actions
• Player - Add X Gold to Player (IntegerA)
?

#### Amigurumi

Level 22
It depends on the income type.
If you want to make an income with special buildings/units:
(The world editor is not open, so it isn't the perfect written trigger)
• Events
• Time - Every 10.00 seconds of game-time
• Conditions
• Actions
• For each Integer A 1 to 12 do Actions
• Loop - Actions
• set IncomeInteger[IntegerA] = 0
• set TempGroup = All units owned by Player Integer A matching unit equal to farm (example)
• Unit Group - Pick every units in TempGroup and do Actions
• Loop - Actions
• set IncomeInteger[IntegerA] = IncomeInteger[IntegerA] + 1
• Player - Add IncomeInteger[IntegerA] Gold to Player[IntegerA]
• Game - Display to Player[IntegerA] the text (Your income: IntegerIncome)
• call DestroyGroup(udg_TempGroup)
If you don't know the exact triggers, tell it, I will look in the editor.

#### Cokemonkey11

Code Reviewer
Level 29
Here are my triggers. One is a "trickle" and the other splits the empire gold among the players.

JASS:
``````function secondGoldA takes nothing returns nothing
local integer index=2
local integer gold
loop
exitwhen index>11
set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
if index<7 then
call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+sgSouth*10)
else
call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+sgNorth*10)
endif
set index=index+1
endloop
endfunction

function InitTrig_secondGold takes nothing returns nothing
set gg_trg_secondGold=CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_secondGold,10,true)
endfunction``````

JASS:
``````function countPlayersInForce takes integer team returns integer
local integer iReturn=0
local integer index
if team==0 then
set index=2
loop
exitwhen index>6
if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
set iReturn=iReturn+1
endif
set index=index+1
endloop
else
set index=7
loop
exitwhen index>11
if GetPlayerSlotState(Player(index))==PLAYER_SLOT_STATE_PLAYING then
set iReturn=iReturn+1
endif
set index=index+1
endloop
endif
return iReturn
endfunction

function empireGoldA takes nothing returns nothing
local integer dTemp
local integer index
local integer gold
call StartSound(gg_snd_Money)
set dTemp=countPlayersInForce(0)
set index=2
loop
exitwhen index>6
set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)
call DisplayTextToPlayer(Player(index),0,0,"You got |cff999900"+I2S(GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)+"|r from your Empire.")
set index=index+1
endloop
call SetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD,0)
set dTemp=countPlayersInForce(1)
set index=7
loop
exitwhen index>11
set gold=GetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD)
call SetPlayerState(Player(index),PLAYER_STATE_RESOURCE_GOLD,gold+GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)
call DisplayTextToPlayer(Player(index),0,0,"You got |cff999900"+I2S(GetPlayerState(Player(0),PLAYER_STATE_RESOURCE_GOLD)/dTemp)+"|r from your Empire.")
set index=index+1
endloop
call SetPlayerState(Player(1),PLAYER_STATE_RESOURCE_GOLD,0)
endfunction

function InitTrig_empireGold takes nothing returns nothing
set gg_trg_empireGold=CreateTrigger()
call TriggerRegisterTimerEvent(gg_trg_empireGold,180,true)
endfunction``````

Status
Not open for further replies.

Replies
3
Views
451
Replies
10
Views
655
Replies
8
Views
837
Replies
14
Views
956
Replies
5
Views
714