Jump to content
Sign in to follow this  
Rawhide

Message to one unit only

Recommended Posts

Hi,

I've searched high and low for this simple solution on my problem. But I must have overlooked it...

The Q:

I would like to give a hint or titleText message to individual units, not the whole group.

Two ways:

A) By the unit that enters a trigger (IE the position of the unit)

B) To named units (IE when a tank is killed, the commander will get a message about this)

Could anyone help meg out please?

Thanks in advance,

-Rawhide

Share this post


Link to post
Share on other sites

i had this same problem, although when i tried what i thought was correct still sent a message to the hole team lol.

Share this post


Link to post
Share on other sites

Text messages using group-, vehicle-, sideChat and hint are local to the computer which uses that command.

Share this post


Link to post
Share on other sites
Text messages using group-, vehicle-, sideChat and hint are local to the computer which uses that command.

So how come when i have a trigger when the player enters it it displays a hint, but the hint goes out to all the other players?

Share this post


Link to post
Share on other sites

Great! Will try this out tonight. I'll report back.

Any idea how I can send a message to a named unit?

In example: a tank is taken out, and a message regarding this goes to the leader(let's name him: leader1).

Thank you so far guys,

-Rawhide

PS! Matt, you don't know how many different things I've tried, triggers and scripts - and try searching for "hint" on this forum  smile_o.gif

Share this post


Link to post
Share on other sites

Event handler are local on the computer where the handler were added.

Share this post


Link to post
Share on other sites
Change condition from "this" to "Player in ThisList".

I'm afraid this didn't work. I thought I had tested it before as well.

Any other tips?

-Rawhide

Share this post


Link to post
Share on other sites

For a tank that is killed and units entering a trigger, try this:

In the leader1 init

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

nil = [leader1] execVM "listen.sqf";

In the tank1 init

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

this addEventHandler["killed", {tankKilled = true; publicVariable "tankKilled";}];

In the trigger On Activation:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

unitsEntered = true; publicVariable "unitsEntered";

In the listen.sqf file

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0;  //assign passed unit to local variable

//infinite loop

while {true} do

{

 //if the tank has been killed

 if (tankKilled) then

 {

   _unit sideChat "The tank has been destroyed.";  //send message

 };

 //if the units have entered the trigger

 if (unitsEntered) then

 {

   _unit sideChat "Units have entered the trigger.";  //send message

 };

 sleep 3;  //wait 3 seconds to ease load on the CPU

};

I haven't tested these, but they should have leader1 receive the messages up to a max of 3 seconds (+ ping time) after it happened.

I haven't had much luck trying to do the same via in-game or script generated triggers. The "player" command seems to have some strange results in dedicated and client-server MP sessions.

Share this post


Link to post
Share on other sites

As I understand it, when a trigger is activated on any client, it will activate on all other clients (even if the activation condition cannot be locally true). This means you need to "filter" the users in the triggers effects. I haven't done any scripting for a while, but try something like this in the onActivation box...

if (player in thisList) then {hint "blah,blah"};

It should hopefully only produce the hint for the first unit within the trigger.

Share this post


Link to post
Share on other sites

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">nil = ...

Never ever do this! Since your overwriting a special variable created by ArmA.

About that trigger:

Trigger only activates on the computers where the condition is fulfilled. It don't starts the trigger on the other computers where the condition is false.

Take a look in OPFEC's Multiplayer Tutorial.

Share this post


Link to post
Share on other sites

Thanks for your help everyone. Thanks to i0n0s' tip about OPFEC's Multiplayer Tutorial, I found this solution to be the easiest for me to use.

Explanation when <span style='color:blue'>one unit is in a area</span>, and <span style='color:red'>when a vehicle is taken out</span>. These messages will in both examples just go to one unit who is named ww5.

<span style='color:blue'>This trigger will send a message to the person, in this case he is named ww5, when he is inside the trigger</span>:

BlueFor, Present.

Condition:

Quote[/b] ]ww5 in thislist

On Act.: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this] exec "messageww5.sqs"

<span style='color:blue'>The script: Giving info to one player (ww5) only:</span>

Scriptname: messageww5.sqs

Script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? local ww5 : titleText ["Target is located at a 150 degrees angle, range approx. 250 meters", "PLAIN DOWN"]

exit

<span style='color:red'>This trigger will go off when a vehicle (car1) is blown up, and will send a message to a unit (still named ww5):</span>

BlueFor, present.

Condition:

Quote[/b] ]!alive car1

On Act.: <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[this] exec "car1ww5.sqs"

<span style='color:red'>The script: Sending message to the unit named ww5 (and now with a hint instead of title text):</span>

Scriptname: car1ww5.sqs

Script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? local ww5 : hint "The car is blown up"

The two triggers will start one script each, and the scripts will tell the player named ww5 - and only ww5 - a message with info.

Thanks again,

-Rawhide

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×