Income system doesn't work!

Dinowc

don't expect anything, prepare for everything
Reaction score
223
can someone explain me why this isn't working?

JASS:
library income initializer init

globals
    public integer array INCOME
    private integer array SALARY
    private group G
endglobals


private function filterFunc takes nothing returns boolean
    local unit u = GetFilterUnit()
    if IsUnitType(u, UNIT_TYPE_STRUCTURE) == false then
        set SALARY[GetPlayerId(GetOwningPlayer(u))] = SALARY[GetPlayerId(GetOwningPlayer(u))] + GetUnitPointValue(u)
    endif
    
    return false
endfunction

private function actions takes nothing returns nothing
    local integer PROFIT = 0
    local integer i = 0
    
    call BJDebugMsg("works?")
    
    call GroupEnumUnitsInRect(G, bj_mapInitialPlayableArea, Condition(function filterFunc))
    
    loop
        set PROFIT = INCOME[GetPlayerId(Player(i))] - SALARY[GetPlayerId(Player(i))]
        
        call SetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD, GetPlayerState(Player(i), PLAYER_STATE_RESOURCE_GOLD) + PROFIT)
        call DisplayTextToForce(bj_FORCE_PLAYER<i>, &quot;INCOME = &quot; + I2S(INCOME[GetPlayerId(Player(i))]) + &quot;; SALARY = &quot; + I2S(SALARY[GetPlayerId(Player(i))]) + &quot;; PROFIT = &quot; + I2S(PROFIT))
        
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    
endfunction

//====================================================

private function init takes nothing returns nothing
    local trigger t = CreateTrigger()
    local integer i = 0
    loop
        set INCOME[GetPlayerId(Player(i))] = 100
        set i = i + 1
        exitwhen i == bj_MAX_PLAYER_SLOTS
    endloop
    
    call TriggerRegisterTimerEvent(t, 30.00, true)
    call TriggerAddAction(t, function actions)
endfunction

endlibrary
</i>


it should give the players gold depending on number of units on the map, but nothing happens...

the debug msg appears though


EDIT: oh I forgot to create the group....

I feel so dumb

nvm
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top