Initialization won't work correctly

AoW_Hun7312

I'm a magic man, I've got magic hands.
Reaction score
76
For some reason my function "countTaggers" won't work correctly. When I debug the Tagger amount, it's always 0, even when I'm player 11 or 12, but the Runner count does increase.

JASS:
library Initialization initializer Init

    globals
        constant integer RUNNER_ID = 'n000'
        constant integer TAGGER_ID = 'H000'
        
        force forceRunners = CreateForce()
        force forceTaggers = CreateForce()
        
        integer runnerCount = 0
        integer taggerCount = 0
    endglobals
    
    function setAlliance takes player toBeConverted returns nothing
        local integer counter = 0
        local player p
        loop
        exitwhen counter > 11
            set p = Player(counter)
            if (toBeConverted != p) then
                if (IsPlayerInForce(p, forceRunners)) then
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_PASSIVE, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_HELP_REQUEST, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_XP, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_PASSIVE, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_HELP_REQUEST, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_HELP_RESPONSE, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_XP, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
                endif
                if (IsPlayerInForce(p, forceTaggers)) then
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_PASSIVE, true)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_HELP_REQUEST, true)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_XP, true)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(toBeConverted, p, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_PASSIVE, true)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_HELP_REQUEST, true)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_HELP_RESPONSE, true)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_XP, true)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_SPELLS, false)
                    call SetPlayerAlliance(p, toBeConverted, ALLIANCE_SHARED_ADVANCED_CONTROL, false)
                endif
            endif
            set counter = counter + 1
        endloop
    endfunction
    
    private function countRunners takes nothing returns nothing
        local integer counter = 0
        local player p
        loop
        exitwhen counter > 9
            set p = Player(counter)
            if (GetPlayerController(p)== MAP_CONTROL_USER) and (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING) then
                call ForceAddPlayer(forceRunners, p)
                call SetPlayerState(p, PLAYER_STATE_GIVES_BOUNTY, 0)
                set runnerCount = runnerCount + 1
                set counter = counter + 1
            endif
        endloop
    endfunction
    
    private function countTaggers takes nothing returns nothing
        local integer counter = 10
        local player p
        loop
        exitwhen counter > 11
            set p = Player(counter)
            if (GetPlayerController(p)== MAP_CONTROL_USER) and (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING) then
                call ForceAddPlayer(forceTaggers, p)
                call SetPlayerState(p, PLAYER_STATE_GIVES_BOUNTY, 0)
                set taggerCount = taggerCount + 1
                set counter = counter + 1
            endif
        endloop
    endfunction
    
    private function Init takes nothing returns nothing
        call countRunners()
        call countTaggers()
    endfunction
        
endlibrary
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
JASS:
            if (GetPlayerController(p)== MAP_CONTROL_USER) and (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING) then
                call ForceAddPlayer(forceTaggers, p)
                call SetPlayerState(p, PLAYER_STATE_GIVES_BOUNTY, 0)
                set taggerCount = taggerCount + 1
                set counter = counter + 1
            endif

To
JASS:
            if (GetPlayerController(p)== MAP_CONTROL_USER) and (GetPlayerSlotState(p) == PLAYER_SLOT_STATE_PLAYING) then
                call ForceAddPlayer(forceTaggers, p)
                call SetPlayerState(p, PLAYER_STATE_GIVES_BOUNTY, 0)
                set taggerCount = taggerCount + 1
           endif
           set counter = counter + 1
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top