Jump to content

Text to specific players in zone


Go to solution Solved by 74DELTA,

Recommended Posts

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

  • Solution

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...