CougarFFW04 Posted December 2, 2021 Share Posted December 2, 2021 Hi everyone, Let's imagine that I have N human flights define in the ME for exemple "Human1", "Human2", "HumanN" Is there a DCS scripting function that could test if a player has entered "Human(whatever)" flight ? Looking forward for a function that would work in solo and MP sessions. I tested simply using the Group.getByName("Human..") but unless i did something wrong it doesn't seems to work for players... thanks Link to comment Share on other sites More sharing options...
CougarFFW04 Posted December 2, 2021 Author Share Posted December 2, 2021 (edited) Hi, investigated and it sounds that in fact Group.getByName("whatever") works even for players flight but that this is a lua problem. here it is : Group.getByName("Enfield") => works BUT if I do something like : tab = { Enfield = {"xxxx", "yyyy"}} for u,v in pairs(tab) do if Group.getByName(u) then don't care what it is doing here... end end it doesn't work... However if I print u it is Enfield and it is a string... So what is going wrong with thus lua code ? Thanks Edited December 2, 2021 by CougarFFW04 Link to comment Share on other sites More sharing options...
Grimes Posted December 2, 2021 Share Posted December 2, 2021 Two schools of thought: 1. Polling a known list. 2. Using events to build a list and polling that. Unit.getByName() would be a reliable means of detecting their state. Or if you save the unit object checking Object.isExist() on it. The right man in the wrong place makes all the difference in the world. Current Projects: Grayflag Server, Scripting Wiki Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread) SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum Link to comment Share on other sites More sharing options...
PravusJSB Posted December 2, 2021 Share Posted December 2, 2021 Are you looking to query the ‘Callsign’? If so you’d have to get the group with the group’s name as you have done above, then with each group ask for the Units or a specific unit of the group then query using the method ‘getCallsign’. Otherwise I might not be fully understanding what string you want to match against as if it’s the groups name then what you have already should work fine. Creator & Developer of XSAF ::An AI model that wants to kill you, and needs no help from humans. Discord: PravusJSB#9484 twitch.tv/pravusjsb https://www.patreon.com/XSAF https://discord.gg/pC9EBe8vWU https://bmc.link/johnsbeaslu Work with me on Fiverr: https://www.fiverr.com/pravusjsb Link to comment Share on other sites More sharing options...
pcoud Posted December 3, 2021 Share Posted December 3, 2021 What do you mean by "it doesn't work" ? The code "don't care what it is doing here..." is not executing ? You are testing Group.getByName(u). Group.getByName(u) will return the object group IF this group actually exists, or (I think, but to be confirmed) nil if it doesn't. Are you sure the group exist when the check is made ? It may be that your code is run before you click on "fly" and therefore executes before you, as a human player, have actually spawned (happened to me numerous times) Link to comment Share on other sites More sharing options...
CougarFFW04 Posted December 3, 2021 Author Share Posted December 3, 2021 3 hours ago, pcoud said: What do you mean by "it doesn't work" ? The code "don't care what it is doing here..." is not executing ? You are testing Group.getByName(u). Group.getByName(u) will return the object group IF this group actually exists, or (I think, but to be confirmed) nil if it doesn't. Are you sure the group exist when the check is made ? It may be that your code is run before you click on "fly" and therefore executes before you, as a human player, have actually spawned (happened to me numerous times) Well in fact it works but 4 o'clock in the morning was probably too late to analyse properly what was going right or wrong Link to comment Share on other sites More sharing options...
Recommended Posts