Marcos Paes Posted November 4, 2023 Posted November 4, 2023 Hello, everyone, and sorry for the question that might seem very silly, but I'm looking to do this in a simple way: how can I count how many people are flying, and have this number of people added to a FLAG? This way, I could more accurately determine the number of enemy aircraft that will take off. We usually fly in groups of 5 to 15 people, and if I plan the mission for 15 people and only 5 show up, it becomes impossible. On the other hand, if I plan for 5 and 15 show up, it becomes too easy. So, I just wanted a script that could count how many aircraft are flying, allowing me to adjust the groups according to this number from the flag! Thank you in advance
Kanelbolle Posted November 4, 2023 Posted November 4, 2023 Hi! You can use coalition.getPlayers for this. See the example on hoggit. https://wiki.hoggitworld.com/view/DCS_func_getPlayers Then sett your flag with trigger.action.setUserFlag https://wiki.hoggitworld.com/view/DCS_func_setUserFlag Hope this helps WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Marcos Paes Posted November 4, 2023 Author Posted November 4, 2023 (edited) I'm really new. i will try to use ur tips. thank you. Do i need Mist to use this commands? I am trying this. but nor working at all local function setFlagForConnectedPlayers() local bluePlayers = coalition.getPlayers(coalition.side.BLUE) for i = 1, #bluePlayers do local playerUnit = bluePlayers[i]:getUnit() if playerUnit and playerUnit:isActive() then local currentFlagValue = trigger.misc.getUserFlag("10") trigger.action.setUserFlag("10", currentFlagValue + 1) env.info("Pilotos Ativos: " .. trigger.misc.getUserFlag("10")) end end end setFlagForConnectedPlayers() Edited November 4, 2023 by Marcos Paes
Marcos Paes Posted November 4, 2023 Author Posted November 4, 2023 UPDATE: This is working: local bluePlayers = coalition.getPlayers(2) for i = 1, #bluePlayers do local playerName = Unit.getName(bluePlayers[i]) env.info("Aumentando FLAG 10 para jogador: " .. playerName) local currentFlagValue = trigger.misc.getUserFlag("10") trigger.action.setUserFlag("10", currentFlagValue + 1) end But everytime the script run, it count again everyone. i want this to ignore already counted active players!
Kanelbolle Posted November 4, 2023 Posted November 4, 2023 (edited) Hi again. If you simply want the amount of players in the mission you don't need to do a loop like the example. Would refrain from using numbers for flag names to, gets confusing fast. local bluePlayers = coalition.getPlayers(2) -- local currentFlagValue = trigger.misc.getUserFlag("PlayerAmount") --Not needed trigger.action.setUserFlag("PlayerAmount", #bluePlayers) env.info("Amount of players: " .. #bluePlayers) Edited November 4, 2023 by Kanelbolle WARGAMES Servers: https://forum.dcs.world/topic/301046-wargames-server-pvp-and-pve-campaign-servers/ Scripts: RGC & SPGG https://github.com/AGluttonForPunishment/
Marcos Paes Posted November 4, 2023 Author Posted November 4, 2023 Thank you i got this trigger.action.outText( 'Total Aircrafts: ' .. trigger.misc.getUserFlag ( '10' ), 5 ) local bluePlayers = coalition.getPlayers(2) trigger.action.setUserFlag("10", #bluePlayers)
Recommended Posts