Heya, I have this code, where I want the unit to train continuesly.
That part works... I just want to know how I can check if the player doesn't have enough money to train the unit, and if he doesn't then say that in a message to him...
Here's my code:
Thought of using the custom value, and just check the custom value of the trained unit, and see if it's higher than the players gold. - but what if more units try to train at the same time? :O
That part works... I just want to know how I can check if the player doesn't have enough money to train the unit, and if he doesn't then say that in a message to him...
Here's my code:
JASS:
scope ProductionContinue initializer Init
private function actions takes nothing returns nothing
local unit u = GetTriggerUnit()
local unit tu = GetTrainedUnit()
local integer uid = GetUnitTypeId(tu)
if (IsUnitType(tu, UNIT_TYPE_ANCIENT)) then
call IssueImmediateOrderById(u, uid)
endif
endfunction
private function Init takes nothing returns nothing
local trigger t = CreateTrigger()
call TriggerRegisterAnyUnitEventBJ(t, EVENT_PLAYER_UNIT_TRAIN_FINISH)
call TriggerAddAction(t, function actions)
endfunction
endscope
Thought of using the custom value, and just check the custom value of the trained unit, and see if it's higher than the players gold. - but what if more units try to train at the same time? :O