74DELTA Posted March 13 Share Posted March 13 Hey Guys, I am trying to display text to a player, or group of players that are within a trigger zone while not displaying the text to players who are not in the specified trigger zone. The script works to display the text as requested but it goes out to all players on the server instead of just the folks in the trigger zone. trying to fix that. As a bonus I cant get the script to play a sound using , ""trigger.action.outSound( file.ogg )"" but that's more of a wish list thing if anyone wants to help. Just found maybe I need to add path to the sound file? "add 'l10n/DEFAULT/'" ? function unitsInZone() local allBlueAircraft = coalition.getGroups(2, 0) -- (1=RED 2=BLUE, 0==AIRCRAFT) local zone = trigger.misc.getZone("CharlieNotice1") for i, group in pairs(allBlueAircraft) do if group ~= nil and group:isExist() == true then local units = group:getUnits() for _i, unit in pairs(units) do local uPos = unit:getPoint() if (((uPos.x - zone.point.x)^2 + (uPos.z - zone.point.z)^2)^0.5 <= zone.radius) then local unitName = unit:getName() trigger.action.outText("Nice flying!: "..unitName, 15) trigger.action.outSound( unitName , Alpha1.ogg ) --other functions can be run here too. end end end end --timer.scheduleFunction(unitsInZone, nil, timer.getTime() + 3) --will run the function every three seconds for the entirety of the mission end unitsInZone() --initiates the function Thanks for any and all assistance. Link to comment Share on other sites More sharing options...
609_Relentov Posted March 13 Share Posted March 13 Maybe use outTextForUnit(...); Here's the page in wiki.hoggitworld.com: https://wiki.hoggitworld.com/view/DCS_func_outTextForUnit Link to comment Share on other sites More sharing options...
74DELTA Posted March 13 Author Share Posted March 13 missed that, thanks will give it a go and update thread. Link to comment Share on other sites More sharing options...
609_Relentov Posted March 13 Share Posted March 13 Good luck. I see in your example you are also outputting sound, and there's a similar function to send sounds to a unit: outSoundForUnit(...), see here: https://wiki.hoggitworld.com/view/DCS_func_outSoundForUnit Link to comment Share on other sites More sharing options...
Solution 74DELTA Posted March 21 Author Solution Share Posted March 21 To accomplish what I needed, the following snippet does work as "requested". Basically for a ring event, when a player is participating in a trigger zone that encompasses the ring event which consists of 5 waves of enemy aircraft, this script identifies the player by unit and sends only them the text message. Thanks for the help! local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'alphatriggerzone'}) for i = 1, #u do local _uName = Unit.getName(u[i]) trigger.action.outText("Good Kill ".. _uName, 2, false) end That is all. thanks! Link to comment Share on other sites More sharing options...
74DELTA Posted March 21 Author Share Posted March 21 Follow up question for you scripting Gods. Will the following structure work to send a different text message to the individual for each different group killed. Not sure how to build that structure properly, but hopefully it's close enough to understand my intent. Thanks. local u = mist.getUnitsInZones(mist.makeUnitTable({'[all]'}), {'alphatriggerzone'}) for i = 1, #u do local _uName = Unit.getName(u[i]) if (Group.getByName('Mig1') and Group.getByName('Mig1'):getSize() < 1) or not Group.getByName('Mig1') then trigger.action.outText("Good Kill ".. _uName, 2, false) else (Group.getByName('Mig2') and Group.getByName('Mig2'):getSize() < 1) or not Group.getByName('Mig1') then trigger.action.outText("Well Done ".. _uName, 2, false) else (Group.getByName('Mig3') and Group.getByName('Mig3'):getSize() < 1) or not Group.getByName('Mig1') then trigger.action.outText("Almost There ".. _uName, 2, false) else (Group.getByName('Mig4') and Group.getByName('Mig4'):getSize() < 1) or not Group.getByName('Mig1') then trigger.action.outText("Way to go! ".. _uName, 2, false) else (Group.getByName('Mig5') and Group.getByName('Mig5'):getSize() < 1) or not Group.getByName('Mig1') then trigger.action.outText("Evolution Completed! ".. _uName, 2, false) end Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now