Jump to content
Sign in to follow this  
simonwa1

Who triggered the trigger?

Recommended Posts

I'm trying to work on a minor radio chat feature for my mission. I at a dead end, because i can't figure out how to get the unit that activated the trigger via radio, since the trigger executes the script on all clients .. ?

Does someone know how to?

Share this post


Link to post
Share on other sites

EDIT: Ignore my suggestion below, I don't think thisList works with radio triggers. I am working on an alternative...

I think thisList works with radio triggers, so, to find out who activated the radio trigger and then pass that unit to the script, try something like this in your On Act. Line (untested):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_activator = thisList select 0; [_activator] execVM "script.sqf";

Then in your script, the unit that activated the trigger can be obtained like this:

<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;

If thisList does NOT work with radio triggers I apologize.

Share this post


Link to post
Share on other sites

Thanks for answer,

But unfortunenly from Wiki:

Quote[/b] ]list: List of units that would activate given Trigger.
sad_o.gif

more suggentions?

Share this post


Link to post
Share on other sites

There is a thread at OFPEC: Script Issue on Dedicated Server, that in part discusses a similar requirement, i.e. getting the name of the player that activated a radio trigger. I am deriving a possible solution from that thread.

Since thisList doesn't work with radio triggers, it is possible that if instead of an editor-placed trigger, you can use a script and the createTrigger command to obtain the name of the player. This would make the trigger "local" and be able to specify the specific player. Here is some possible code (EDIT: Tested and working!):

Code somewhere within the init.sqf:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_nul = [] execVM "RadioTrigger.sqf";

EDIT: I originally forgot to double quote for the publicVariable command. I have corrected it below.

RadioTrigger.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">radioAlpha = createTrigger["EmptyDetector",getPos player];

radioAlpha setTriggerArea[0,0,0,false];

radioAlpha setTriggerText "Do Something";

radioAlpha setTriggerActivation["ALPHA","PRESENT",true];

radioAlpha setTriggerStatements["this", "activator = player; publicVariable ""activator""; alphaActivated = true; publicVariable ""alphaActivated""", ""];

Ok, so now when a specific player activates the radio trigger, that player should be broadcasted as the public variable activator to all clients. Additionally, alphaActivated should also be broadcasted publically with the value of true.

Now, we need another trigger (this one CAN be placed in the editor) with the following Condition and On Act:

Cond: alphaActivated

On Act. nul = [] execVM "OtherScript.sqf";

When alphaActivated returns true (after it is pV'd), it will launch your script on ALL clients.

OtherScript.sqf

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[West,"HQ"] sidechat format["%1 activated the radio trigger", (name activator)];

EDIT: I tested this on a multiple client dedicated server and it works fine for both clients.

Share this post


Link to post
Share on other sites

How do you limit the radio alpha for example only player named "johhny"?

Share this post


Link to post
Share on other sites
How do you limit the radio alpha for example only player named "johhny"?

I haven't tried this, but I think if you enter the code below into the init line of all the units you DON't want to have the radio command, they will not see, and therefore cannot use the radio command. (this would be Radio Alpha, 2 would be Radio bravo, etc.):

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

This could be done in a script as well or with triggers too of course.

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  

×