• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

Leaving player is not being removed from groups

Status
Not open for further replies.
Level 24
Joined
Jun 26, 2020
Messages
1,853
I have two groups, one is to the players present players and the other is for who are not afk, but I don't know why but I have the action to remove them from those groups but they are still counted as they are still there why?

This is the trigger:
  • Se fue
    • Events
      • Player - Player 2 (blue) leaves the game
      • Player - Player 3 (teal) leaves the game
      • Player - Player 4 (purple) leaves the game
      • Player - Player 5 (yellow) leaves the game
      • Player - Player 6 (orange) leaves the game
      • Player - Player 8 (pink) leaves the game
      • Player - Player 9 (gray) leaves the game
      • Player - Player 10 (light blue) leaves the game
      • Player - Player 11 (dark green) leaves the game
      • Player - Player 12 (brown) leaves the game
    • Conditions
    • Actions
      • Set Temp_Player = (Triggering player)
      • Sound - Play UpkeepRing <gen>
      • Custom script: set udg_Atemp_Int=CircleNumber(udg_Temp_Player)
      • Player Group - Remove Temp_Player from Los_que_estan
      • Player Group - Remove Temp_Player from Esta_jugando
      • Set AFK_tiempo[Atemp_Int] = 0.00
      • Game - Display to (All players) for 10.00 seconds the text: (Nombre_Player[Atemp_Int] + |cffff0000left the game.|r)
      • Custom script: call MultiboardSetItemValueMejor(udg_Tabla,2,udg_Row[udg_Atemp_Int],GetPlayerName(udg_Temp_Player))
      • Custom script: call MultiboardSetItemColorMejor(udg_Tabla,0,udg_Row[udg_Atemp_Int],105,105,105,255)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Temp_Player is in Selector_de_modos) Igual a True
        • Then - Actions
          • Player Group - Remove all players from Selector_de_modos
          • Trigger - Run Quien selecciona el modo <gen> (ignoring conditions)
        • Else - Actions
      • Item - Pick every item in (Playable map area) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Owner of (Picked item)) Igual a Temp_Player
            • Then - Actions
              • Set Temp_Loc = (Center of Circle_region[Atemp_Int])
              • Item - Move (Picked item) to Temp_Loc
              • Custom script: call RemoveLocation(udg_Temp_Loc)
              • Item - Change ownership of (Picked item) to Neutral pasivo and Cambiar color
            • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Remaining time for End_Switch) Mayor que 0.00
        • Then - Actions
          • Trigger - Run No <gen> (checking conditions)
          • Custom script: call DestroyTimer(udg_End_Switch)
          • Custom script: set udg_End_Switch=CreateTimer()
        • Else - Actions
And this the trigger where I have problems, this is when you wanna switch team and the other players must been agreed
  • Ok
    • Events
      • Player - Player 2 (blue) types a chat message containing -ok as An exact match
      • Player - Player 3 (teal) types a chat message containing -ok as An exact match
      • Player - Player 4 (purple) types a chat message containing -ok as An exact match
      • Player - Player 5 (yellow) types a chat message containing -ok as An exact match
      • Player - Player 6 (orange) types a chat message containing -ok as An exact match
      • Player - Player 8 (pink) types a chat message containing -ok as An exact match
      • Player - Player 9 (gray) types a chat message containing -ok as An exact match
      • Player - Player 10 (light blue) types a chat message containing -ok as An exact match
      • Player - Player 11 (dark green) types a chat message containing -ok as An exact match
      • Player - Player 12 (brown) types a chat message containing -ok as An exact match
    • Conditions
    • Actions
      • If (((Triggering player) is in Ya_votaste) Equal to True) then do (Skip remaining actions) else do (Do nothing)
      • Set Los_que_votaron = (Los_que_votaron + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Los_que_votaron Not equal to (Number of players in Los_que_estan)
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( typed ok + ((( + (String(Los_que_votaron))) + (/ + ((String((Number of players in Los_que_estan))) + ))))))
          • Player Group - Add (Triggering player) to Ya_votaste
        • Else - Actions
          • Trigger - Run Cambio <gen> (checking conditions)
          • Set Los_que_votaron = 1
          • Player Group - Remove all players from Ya_votaste
          • Game - Display to (All players) the text: The switch has been...
          • Trigger - Turn off No <gen>
          • Trigger - Turn off (This trigger)
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,202
You need to explain more clearly how your current triggers are breaking. Such as what you do, what happens and what should happen instead.

Removing a player from a player group (force JASS type) will remove them from it correctly. It will only fail to do so if the player group was destroyed or if the unit was not in the player group to remove them in the first place.

I recommend debugging your logic with messages to try and see where it goes wrong. First make sure the involved triggers run to completion, and do not suffer a thread crash part way. Then try to see if the player groups contain what you expect them to at the times you expect them to. Then try to see if the player groups are manipulated correctly, not removing or adding players that should not be. It might not even be related to the player groups so you might have to check the logic around them.
 
Level 24
Joined
Jun 26, 2020
Messages
1,853
I never did anything with playergroups.. but i saw a thread about leaks and i readed that Playergroups leak a lot...

what if you set all players to an player[array]

and if one leave you just destroy the Playergroup and recreate it and put the others back in?

correct me if I’m wrong just brainstorming..
My triggers don't have memory leaks, "All players" is a constant and never leak.
You need to explain more clearly how your current triggers are breaking. Such as what you do, what happens and what should happen instead.

Removing a player from a player group (force JASS type) will remove them from it correctly. It will only fail to do so if the player group was destroyed or if the unit was not in the player group to remove them in the first place.

I recommend debugging your logic with messages to try and see where it goes wrong. First make sure the involved triggers run to completion, and do not suffer a thread crash part way. Then try to see if the player groups contain what you expect them to at the times you expect them to. Then try to see if the player groups are manipulated correctly, not removing or adding players that should not be. It might not even be related to the player groups so you might have to check the logic around them.
Ok, the problem is I in this case I have to player groups "Los_que_estan" those who aren't afk and "Esta_jugando" those who are in-game, to create this group I used the force "All Players" that for some reason it only counts the present players (even computer and not the neutrals), so to the force "Esta_jugando" I just assing those from "All Players" who aren't I know they are computer because I heard the conditions "Player Slot" can cause desyncs (but thinking well, I have to use it anyway because the players can add bots but I don't know why), to the force "Los_que_estan" I basically check those players are doing something:
vJASS:
function Trig_A_ver_si_estas_Actions takes nothing returns nothing
    local player p=GetTriggerPlayer()
    local integer i=CircleNumber(p)
    set udg_AFK_tiempo[i]=0.00
    if not IsPlayerInForce(p,udg_Los_que_estan) then
        call ForceAddPlayer(udg_Los_que_estan,p)
        call MultiboardSetItemColorMejor(udg_Tabla,0,udg_Row[i],255,255,255,255)
        call MultiboardSetItemValueMejor(udg_Tabla,2,udg_Row[i],udg_Nombre_Jugador[i])
    endif
    set p=null
endfunction

//===========================================================================
function InitTrig_A_ver_si_estas takes nothing returns nothing
    local integer i=1
    set gg_trg_A_ver_si_estas=CreateTrigger()
    loop
        exitwhen i>11
        if i!=6 then
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_SELECTED,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_DESELECTED,null)
            call TriggerRegisterPlayerChatEvent(gg_trg_A_ver_si_estas,Player(i),"",false)
            call TriggerRegisterPlayerEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_END_CINEMATIC)
            call TriggerRegisterPlayerEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_ALLIANCE_CHANGED)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_ORDER,null)
        endif
        set i=i+1
    endloop
    call TriggerAddAction(gg_trg_A_ver_si_estas,function Trig_A_ver_si_estas_Actions)
endfunction
The problem is in this trigger
  • Ok
    • Events
      • Player - Player 2 (blue) types a chat message containing -ok as An exact match
      • Player - Player 3 (teal) types a chat message containing -ok as An exact match
      • Player - Player 4 (purple) types a chat message containing -ok as An exact match
      • Player - Player 5 (yellow) types a chat message containing -ok as An exact match
      • Player - Player 6 (orange) types a chat message containing -ok as An exact match
      • Player - Player 8 (pink) types a chat message containing -ok as An exact match
      • Player - Player 9 (gray) types a chat message containing -ok as An exact match
      • Player - Player 10 (light blue) types a chat message containing -ok as An exact match
      • Player - Player 11 (dark green) types a chat message containing -ok as An exact match
      • Player - Player 12 (brown) types a chat message containing -ok as An exact match
    • Conditions
    • Actions
      • If (((Triggering player) is in Ya_votaste) Equal to True) then do (Skip remaining actions) else do (Do nothing)
      • Set Los_que_votaron = (Los_que_votaron + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Los_que_votaron Not equal to (Number of players in Los_que_estan)
        • Then - Actions
          • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( typed ok + ((( + (String(Los_que_votaron))) + (/ + ((String((Number of players in Los_que_estan))) + ))))))
          • Player Group - Add (Triggering player) to Ya_votaste
        • Else - Actions
          • Trigger - Run Cambio <gen> (checking conditions)
          • Set Los_que_votaron = 1
          • Player Group - Remove all players from Ya_votaste
          • Game - Display to (All players) the text: The switch has been...
          • Trigger - Turn off No <gen>
          • Trigger - Turn off (This trigger)
In this part:
  • If - Conditions
    • Los_que_votaron Not equal to (Number of players in Los_que_estan)
    • Then - Actions
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( typed ok + ((( + (String(Los_que_votaron))) + (/ + ((String((Number of players in Los_que_estan))) + ))))))
Imagine they are initially 6 active players, so (Number of players in Los_que_estan) returns 6, but 2 left, so it must return 4, but in my case is still returning 6, even when I have this in the trigger where they left:
  • Player Group - Remove Temp_Player from Los_que_estan
And there is my problem.
 
Level 6
Joined
Dec 29, 2019
Messages
82
My triggers don't have memory leaks, "All players" is a constant and never leak.

Ok, the problem is I in this case I have to player groups "Los_que_estan" those who aren't afk and "Esta_jugando" those who are in-game, to create this group I used the force "All Players" that for some reason it only counts the present players (even computer and not the neutrals), so to the force "Esta_jugando" I just assing those from "All Players" who aren't I know they are computer because I heard the conditions "Player Slot" can cause desyncs (but thinking well, I have to use it anyway because the players can add bots but I don't know why), to the force "Los_que_estan" I basically check those players are doing something:
vJASS:
function Trig_A_ver_si_estas_Actions takes nothing returns nothing
    local player p=GetTriggerPlayer()
    local integer i=CircleNumber(p)
    set udg_AFK_tiempo[i]=0.00
    if not IsPlayerInForce(p,udg_Los_que_estan) then
        call ForceAddPlayer(udg_Los_que_estan,p)
        call MultiboardSetItemColorMejor(udg_Tabla,0,udg_Row[i],255,255,255,255)
        call MultiboardSetItemValueMejor(udg_Tabla,2,udg_Row[i],udg_Nombre_Jugador[i])
    endif
    set p=null
endfunction

//===========================================================================
function InitTrig_A_ver_si_estas takes nothing returns nothing
    local integer i=1
    set gg_trg_A_ver_si_estas=CreateTrigger()
    loop
        exitwhen i>11
        if i!=6 then
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_SELECTED,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_DESELECTED,null)
            call TriggerRegisterPlayerChatEvent(gg_trg_A_ver_si_estas,Player(i),"",false)
            call TriggerRegisterPlayerEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_END_CINEMATIC)
            call TriggerRegisterPlayerEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_ALLIANCE_CHANGED)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_TARGET_ORDER,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_POINT_ORDER,null)
            call TriggerRegisterPlayerUnitEvent(gg_trg_A_ver_si_estas,Player(i),EVENT_PLAYER_UNIT_ISSUED_ORDER,null)
        endif
        set i=i+1
    endloop
    call TriggerAddAction(gg_trg_A_ver_si_estas,function Trig_A_ver_si_estas_Actions)
endfunction
The problem is in this trigger

In this part:
  • If - Conditions
    • Los_que_votaron Not equal to (Number of players in Los_que_estan)
    • Then - Actions
      • Game - Display to (All players) the text: ((Name of (Triggering player)) + ( typed ok + ((( + (String(Los_que_votaron))) + (/ + ((String((Number of players in Los_que_estan))) + ))))))
Imagine they are initially 6 active players, so (Number of players in Los_que_estan) returns 6, but 2 left, so it must return 4, but in my case is still returning 6, even when I have this in the trigger where they left:
  • Player Group - Remove Temp_Player from Los_que_estan
And there is my problem.
1st. Try to avoid naming convention in your mutual language ... if it's not english... it's confusing for everyone who doesn't speak it.
2nd. what does CircleNumber(player) function do ?
3rd. if player leaves won't it be controlled by computer ? I mean even if AI won't do anything it can probably run one of these triggers and they will be added into Los_que_estan even after Player has left the game
1617295260239.png


try to add condition into your Trig_A_ver_si_estas_Actions function
if not IsPlayerInForce(p,udg_Los_que_estan) and GetPlayerSlotState(p) != PLAYER_SLOT_STATE_LEFT then

4th.
if you want further help you need to send us every part of your GUI / code where you add players into udg_Los_que_estan force
 
Level 24
Joined
Jun 26, 2020
Messages
1,853
1st. Try to avoid naming convention in your mutual language ... if it's not english... it's confusing for everyone who doesn't speak it.
2nd. what does CircleNumber(player) function do ?
3rd. if player leaves won't it be controlled by computer ? I mean even if AI won't do anything it can probably run one of these triggers and they will be added into Los_que_estan even after Player has left the game
View attachment 376591

try to add condition into your Trig_A_ver_si_estas_Actions function
if not IsPlayerInForce(p,udg_Los_que_estan) and GetPlayerSlotState(p) != PLAYER_SLOT_STATE_LEFT then

4th.
if you want further help you need to send us every part of your GUI / code where you add players into udg_Los_que_estan force
1) Ay
2) To index the players I think to append them to a circle that is in the map, because I know they never change, because they can switch teams, but at this point I know I just have to append them to a variable and just change the index when they change team, just I did this when I was new on this and I'm too lazy to change that now.
3) I was planning to remove the player's units when the player leaves, but well, I can try this, but I heard checking the slot can cause desyncs or not?
4) I have this code in the initialization trigger (with event "Game-time 0.00")
vJASS:
function Inicio_Funcion6 takes nothing returns nothing
    if GetEnumPlayer()!=Player(0) and GetEnumPlayer()!=Player(6) then
        call ForceAddPlayer(udg_Esta_jugando,GetEnumPlayer())
    endif
endfunction

call ForForce(bj_FORCE_ALL_PLAYERS,function Inicio_Funcion6)
 
Level 6
Joined
Dec 29, 2019
Messages
82
1) Ay
2) To index the players I think to append them to a circle that is in the map, because I know they never change, because they can switch teams, but at this point I know I just have to append them to a variable and just change the index when they change team, just I did this when I was new on this and I'm too lazy to change that now.
3) I was planning to remove the player's units when the player leaves, but well, I can try this, but I heard checking the slot can cause desyncs or not?
4) I have this code in the initialization trigger (with event "Game-time 0.00")
vJASS:
function Inicio_Funcion6 takes nothing returns nothing
    if GetEnumPlayer()!=Player(0) and GetEnumPlayer()!=Player(6) then
        call ForceAddPlayer(udg_Esta_jugando,GetEnumPlayer())
    endif
endfunction

call ForForce(bj_FORCE_ALL_PLAYERS,function Inicio_Funcion6)
Hmm i dont know about desync stuff, maybe just test it ... on my multiplayer project it wasn't any problem, but it was like 8 years ago ... so idk about new versions of game
 
Status
Not open for further replies.
Top