Jump to content
Sign in to follow this  
MrBurtyyy

Selecting specific unit in script

Recommended Posts

Dear users,

I have been lately getting into scripting for Arma 3 as I am creating a training map for the realism unit I am in. I have been creating simple scripts that allow players to select pre-defined loadouts and am using a trigger to give the actions to the player.

The problem I have is that when a player enters the trigger, he is given the options to change and it does work, however the options are also given to every other player in the server even if they are not in the trigger's AOE.

AddActions.sqf

ActionID1 = player addAction ['<t color="#FFFF00">' + "Officer Uniform (On Base)" + '</t>', "scripts\1stSFGLoadouts\BLUFOR\OfficerUniform.sqf"];
ActionID2 = player addAction ['<t color="#FFFF00">' + "Recruit Uniform (On Base)" + '</t>', "scripts\1stSFGLoadouts\BLUFOR\RecruitUniform.sqf"];
ActionID3 = player addAction ['<t color="#FFFF00">' + "CADRE Uniform" + '</t>', "scripts\1stSFGLoadouts\BLUFOR\CADREUniform.sqf"];
ActionID4 = player addAction ['<t color="#FFFF00">' + "Enlisted Uniform" + '</t>', "scripts\1stSFGLoadouts\BLUFOR\EnlistedUniform.sqf"];
ActionID5 = player addAction ['<t color="#FFFF00">' + "HALO Uniform" + '</t>', "scripts\1stSFGLoadouts\BLUFOR\HALOUniform.sqf"];

That is the script that is run when the trigger is activated.

The onAct command that I am using in the trigger is:

player exec "scripts\1stSFGLoadouts\AddActions.sqf";

What I am needing is a way to select the unit that entered the trigger area and give them the actions instead of everyone in the server. Once the player leaves the area a script is run to remove all the actions given by that trigger.

Any help will be appreciated and thank you in advance :)

Share this post


Link to post
Share on other sites

although this is in the forums you can fix that with this in your condition field of the trigger:

condition:

local player && this

Share this post


Link to post
Share on other sites

This didn't work :/ It now gives the actions to all players on the map at all times, even if they are not in the triggers AOE. Anything that I may have done wrong?

Share this post


Link to post
Share on other sites

You'll find questions like this have been asked many times before. Do a google search or search within the forum directly and you'll probably find what you are after. I had a quick look on your behalf, have a look at this thread.

Mondkalb appears to have the answer to your question:

Alternatively to make the entry only show when the player is in a trigger (activated by the player's side, repeatedly and named "trigger1Name")
_actionId = this addAction ["Free Captives", "free.sqf", [], 1, false, true, "", "driver player == player and _target in list trigger1Name"];

driver player == player

This part ensures that the action menu entry is only visible to the person attached to.

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  

×