Jump to content
avibird 1

addAction code to allow only certain players to use it. Should this work!

Recommended Posts

Should this code work!

CODE: this addAction[" Acquisition Request for Personnel", " recruitment.sqf", nil, 6, True, True, "", "(_target distance _this) < 4 && _this == name of unit"]

Now will the player with the name of the unit be the only one to see the action and use it.

Share this post


Link to post
Share on other sites

Yes, so long as "name of unit" is legitimate.

Share this post


Link to post
Share on other sites

@ jshock thank you for the help however I had a typo and added units name but not working anyunit can use the addaction still

this addAction[" Acquisition Request for Personnel", " recruitment.sqf", nil, 6, True, True, "", "(_target distance _this) < 4 && _this == Raven_SL]

 

 

I am using Bon's Infantry Recruitment Redux the way it is setup any unit can recruit

Simple AI Recruitment Dialog / Script by Dadds Army the setup is only the squad leader can recruit. I will try the code with that script to see if it works.

 

I only want a few squad leaders to have the ability to recruit during the mission. That is my goal.

Share this post


Link to post
Share on other sites

Use get/set variable in the init field of your SLs that you allow access, then adapt your condtion code with that

Share this post


Link to post
Share on other sites

@ jshock I don't really follow you when you say Use get/set variable in the init field. From your first post you said the only thing  I needed was for my unit  to have a legitimate name. Actually I did not really know what you were talking about a  legitimate name.  The editor will not allow you to write an improper name. All the playable units were placed down via editor with proper names. An example would be very nice thank you in advanced Avibird.

Share this post


Link to post
Share on other sites

Yea sorry, was working from my phone when I replied, hoping that you could figure it out :P:

//in SL's init field
this setVariable ["allowRecruitment",true];


//action
this addAction
[
	"Acquisition Request for Personnel", 
	"recruitment.sqf", 
	nil, 
	6, 
	true, 
	true, 
	"", 
	"(_target distance _this) < 4 && _this getVariable ['allowRecruitment',false]"
];

And with what I said earlier I wasn't whole-fully clear on what you had done, but get/set variable would have been my preferred method anyhow.

Share this post


Link to post
Share on other sites

I will try when I get on the PC. I do appreciate the feedback and the direction but sometimes you more advanced guys talk over our heads. I know I have been here for a while and been playing OFP-ARMA for a long time but my scripting knowledge is still Limited but my mission designs are extremely advanced in concepts and that my friend gets me into a lot of trouble lol.

Share this post


Link to post
Share on other sites

@Jshock  how do I combine both of these code into one.

 

 

 

_this == Raven_SL"]

and

 

_this getVariable ['allowRecruitment',false]" 

they both work separate but still let any unit  recruit units from the flag pole that the code is in. When I try add them together I get an error.

 

 

This is it with then TL_name

this addAction["Acquisition Request for Personnel", "recruitment.sqf", nil, 6, True, True, "(_target distance _this) < 4 && _this == Raven_SL"]                                          

This is with the getVariable

this addAction["Acquisition Request for Personnel", "recruitment.sqf", nil, 6, True, True, "(_target distance _this) < 4 && _this getVariable ['allowRecruitment',false]" 

both work to allow for recruitment of units but not to limit who can get the addaction. How do I add the two.

Share this post


Link to post
Share on other sites

So in the SL/TL init fields you put the following correct?:

this setVariable ["allowRecruitment",true];

That should make it where the only units that can "see" the action are those that you put the above in their init fields.

Share this post


Link to post
Share on other sites

yes I know that but what is the proper way to add

 

_this == Raven_SL"] and  _this setVariable ["allowRecruitment",true];

 

 

to  this addAction["Acquisition Request for Personnel", "recruitment.sqf", nil, 6, True, True, "(_target distance _this) < 4 && (how to I add it to this code I keep getting errors when I add both to the code in green. That is what I am asking.

Share this post


Link to post
Share on other sites

Nonsense but why not, here you have

//in SL's init field
this setVariable ["allowRecruitment",true];


//action
this addAction
[
	"Acquisition Request for Personnel", 
	"recruitment.sqf", 
	nil, 
	6, 
	true, 
	true, 
	"", 
	"(_target distance _this) < 4 && _this getVariable ['allowRecruitment',false] && _this == Raven_SL"
];

Share this post


Link to post
Share on other sites

Davidoss I will give it a go I think I attempted that cobination already.

Share this post


Link to post
Share on other sites

@ davidoss thank you but no luck all units can still get the addaction.

 

@jshock  can you show me what you mean about this vehicleVarName _this == Raven_SL

Share this post


Link to post
Share on other sites

Instead of:

_this == Raven_SL

use-

vehicleVarName _this == Raven_SL

all together-

"(_target distance _this) < 4 && _this getVariable ['allowRecruitment',false] && vehicleVarName _this == Raven_SL"

Share this post


Link to post
Share on other sites

still no good all units can use the addaction still :(

Share this post


Link to post
Share on other sites

still no good all units can use the addaction still :(

 

Well, I would give up, call you crazy, and just leave this thread be.....however......I just made a quick test mission, and it seems addAction doesn't work on flag poles for whatever particular reason. I have a flag pole and an ammo crate with the same exact code in their init's, and two playable characters one with the variable "allowRecruitment" set to true, and the other without, yet, the pole had no action and the ammo crate had it.

 

https://www.dropbox.com/s/8oskh3xrimkx2le/addAction_Test.VR.zip?dl=0

Share this post


Link to post
Share on other sites

hey jshock first I never give up second yes I am a bit crazy and third thank you I see your example does work for sure. I am going to see why it did not work using Bon's Infantry Recruitment Redux script.

Share this post


Link to post
Share on other sites

hey jshock first I never give up second yes I am a bit crazy and third thank you I see your example does work for sure. I am going to see why it did not work using Bon's Infantry Recruitment Redux script.

 

It's not the script, I don't believe, the flag pole itself doesn't allow actions to be added....so....I have no clue if it's me or what, but it's definitely weird.

Share this post


Link to post
Share on other sites

The whole flag pole thing is very weird it always worked that way with ARMA2 and in this same mission I have an addaction halo jump and vehicle spawn using a flag pole.
 
The second thing I found was the this setVariable ["allowRecruitment",true];  was not working in my units init because I had some other code lines before it. When I put it at the start of the init box it worked.

 

 

Third  I guess I really don't need this code && vehicleVarName _this == Raven_SL" for it to allow only that unit to recruit units.

 

jshock thank you again sir for the assist I guess it was a good night 1 of 2 main issues fixed lol

Share this post


Link to post
Share on other sites

hey I think I found the issue with your code.

 

This is your code that does not allow the flag pole to have the addaction only the ammo box.

 

this addAction  [   "Recruit People",   {    hint "New People!!";   },   nil,   6,   true,   true,   "",   "((_this distance _target) < 4) && (_this getVariable ['allowRecruitment',false])"  ];

 

If you take out this  "",  

 

Then the addaction works on the flag pole but every unit can use it now. Why!

 

The rest is up to you and others this is way over my understanding of scripting :D I have what I need to move forward with my project but still want to know why.

Share this post


Link to post
Share on other sites

Ok, with further testing, it seems the "center" of the flag pole is not at ground level, but halfway up the pole itself, therefore, on the distance check, the action doesn't show up until you are basically right on top of the flag pole, so for sake of it working, take out the distance check in the condition, leaving just the variable check:

"(_this getVariable ['allowRecruitment',false])"
  • Like 1

Share this post


Link to post
Share on other sites

IDK but if you take it out  "",    then the addaction can be called from the flag pole for anyone. If you keep it in no addaction from flag pole but only the unit with the this getVariable 'allowRecruitment',false"  will get the addaction on all other objects excluding the flag pole. This makes my head hurt. good night and thank you again.

Share this post


Link to post
Share on other sites

AVIBIRD 1

Firstly flag poles do allow actions but different objects react differently to the distance check you have in your condition. Play with extending it until you a value you want. Default is 15m before the condition is even checked.

Secondly, a condition you could use is "(((_this distance _target) < 10)&& (_this == (leader (group _this))))" this will allow any player within the range, who is the leader of its group to run the action. Allowing for deaths of the actual SL unit.

No need for setVariable calls.

Depending on the mission type and MP compatibility req, the action needs to be added to the flag pole on every player client as it's a local command. If that player becomes the SL of the unit via field promotion they can then use the action.

This is easily done by putting it in the init.sqf instead of the init line of the editor.

Just name the flag pole FLAGPOLE (for example) in the editor and in the init.sqf put:

If(hasInterface) then {

waitUntil {player == player};

FLAGPOLE addAction { //your action ending with the condition supplied above.}

};

Should be JIP compatible etc.

Slightly odd, talks to pixels

  • Like 1

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

×