Mateos Posted November 12, 2020 Share Posted November 12, 2020 Good afternoon, I'd like to cycle through the players (not just bots!) from a team to check if they are in a AABB area; I'd like to count them when they're alive (so not dead nor waiting for a Medic) First check can be ETUtil.IsTeamDead, but that's ofc not enoughI know how to cycle through bots with BotTable, and there seemed to be a function in the Bot library that could help but it is marked as deprecated (IsWaitingForMedic), and probably just work for bots? So I'm looking for the elements to build a loop to go through the players, and just for a particular team check if their position is inside the AABB while being able to walk... Basically just counting themI can then just sort a % with Server.Team[ team ].NumPlayers and say tell if the area is 'safe' for the other team to like secure an objective Could someone please point me to the right direction? I haven't found an example in the scripts (perhaps I'm just bad at searching ^^') Thanks Quote Link to comment Share on other sites More sharing options...
Moderators palota Posted November 14, 2020 Moderators Share Posted November 14, 2020 Cycle through all players may be slow, so I would recommend to create a trigger region. Then define some table in your script to store all players who are in the region. Add a player to the table in OnEnter and remove him from the table in OnExit. Then build a loop to go through players in that table and count only those who have Util.GetEntHealth(ent)>0. Mateos 1 Quote Link to comment Share on other sites More sharing options...
Mateos Posted November 14, 2020 Author Share Posted November 14, 2020 (edited) That were the first thought I had, I'll have to protect that table writing with a mutual exclusion because I will do that check not only on Enter/Exit events but through a thread that will be running while the objective is taken... But if that's faster than cycling through players then I'll go this way Will I have to be careful with disconnections? Like in the role management in the OB internal GM scripts, or do they trigger the Exit event? Edited November 14, 2020 by Mateos Quote Link to comment Share on other sites More sharing options...
Mateos Posted November 16, 2020 Author Share Posted November 16, 2020 Tested and it's fine as long as the Team isn't tested, may it be team switch/joining spec/disconnecting Quote Link to comment Share on other sites More sharing options...
Moderators palota Posted November 17, 2020 Moderators Share Posted November 17, 2020 Function OnExit can be called after a player switched team or disconnected. There are too many maps with this "team switch bug". I fixed it in the fueldump map today.GameMonkey scripts have simple cooperative multitasking. Threads can be switched only at sleep or yield. That's why no locks or mutexes are needed. Mateos 1 Quote Link to comment Share on other sites More sharing options...
Mateos Posted November 17, 2020 Author Share Posted November 17, 2020 (edited) Yup, I've seen your commit earlier, I'll simplify my waypoints accordingly (especially that setting a null will affect tableCount accordingly) So that means the next OnExit is called after the previous one is over if no sleep/yield, that will also simplify the thingy! Thank you very much! Edited November 17, 2020 by Mateos Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.