Creating doubles

ArmyOfFrogs

New Member
Reaction score
20
Trigger keeps spawning 2 units rather than just 1.

Trigger:
  • Give
    • Events
      • Time - Elapsed game time is 8.00 seconds
    • Conditions
    • Actions
      • Set tmp_Point = (Center of PlayerNewStart <gen>)
      • For each (Integer A) from 0 to PlayersActive, do (Actions)
        • Loop - Actions
          • Unit - Create 1 Footman for Player[(Integer A)] at tmp_Point facing Default building facing degrees
      • Custom script: call RemoveLocation (udg_tmp_Point)


Here is what sets Player

Trigger:
  • PlayerSet
    • Events
      • Time - Elapsed game time is 0.10 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players controlled by a User player) and do (Actions)
        • Loop - Actions
          • Set PlayerSetCount = (PlayerSetCount + 1)
          • Set Player[PlayerSetCount] = (Picked player)


and PlayersActive is just count players in all players matching controlled by user.

Can anyone spot the error?
 

bOb666777

Stand against the ugly world domination face!
Reaction score
117
Why don't you just Pick all players matching Is controlled by a user and do Create 1 footman for picked player?
 

ArmyOfFrogs

New Member
Reaction score
20
Eh I'm trying to practice JASS and I was writing triggers, then went to test them and duplicates of certain triggers ran, so the footman creation is just a dummy one that I made to try and narrow down the variable that is going wrong o_O
Here's the PlayersActive that's involved and JASS.
JASS:
function Trig_PlayersActive_Actions takes nothing returns nothing
    set udg_PlayersActive = CountPlayersInForceBJ(GetPlayersByMapControl(MAP_CONTROL_USER))
endfunction

//===========================================================================
function InitTrig_PlayersActive takes nothing returns nothing
    set gg_trg_PlayersActive = CreateTrigger(  )
    call TriggerAddAction( gg_trg_PlayersActive, function Trig_PlayersActive_Actions )
endfunction
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
Your loop is from 0 to PlayersActive. Does PlayersActive start counting at 0 for one player, or 1? If 1, it will spawn a unit twice (with one player) because the loop will run twice; starting at 0, and again at 1.
 

ArmyOfFrogs

New Member
Reaction score
20
I found the problem, it was in another trigger it was using the player variable and it got messed with there.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top