Jump to content
Sign in to follow this  
kocrachon

AddAction script help.

Recommended Posts

So right now I am making a mission where a guy gets into a commander spot of an LAV MHQ. I am using the mado mission arma add-on for the UAV. I am trying to make a pilot who is the only one who can enter the spot, and I am trying to make it so that he also cant get into the driver spot because it has an AI driver.

So to do this I have locked the vehicle and I am allowing him to get in via scripts. Right now my scripts go like this..

I have a trigger attached to the MHQ and when he enters the range it does this..

_uavin = RESCUE2 addAction ["Get In", "getin.sqf"]

With the getin.sqf I have this

RESCUE2 moveincommander UAVMHQ;

RESCUE2 removeAction _uavin;

_uavout = RESCUE2 addAction ["Get Out", "getout.sqf"];

However, the Get Out portion isn't working. The "Get Out" Doesnt show up in the actions menu. Anyone able to help me out with this?

Here is my get out script.

(commander UAVMHQ) action ["eject", UAVMHQ]);

Share this post


Link to post
Share on other sites

addaction passes multiple vars to the script and those are accessed as follows

_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;

caller is the unit activating the addaction, host is the object where the addaction is attached to and id is the action ref. to have another addaction launch from the script and work properly you need to use _caller instead of the hostname.

_caller moveincommander UAVMHQ;

_caller removeAction _uavin;

_uavout = _caller addAction ["Get Out", "getout.sqf"];

that should work. or you could use _host too if you would like for getout.

http://community.bistudio.com/wiki/addAction

Share this post


Link to post
Share on other sites

unfortunatly, the "Get Out" action is still not showing up, even with those changes.

_host = _this select 0;

_caller = _this select 1;

_id = _this select 2;

_caller moveincommander UAVMHQ;

_caller removeAction _uavin;

_uavout = _caller addAction ["Get Out", "getout.sqf"];

Share this post


Link to post
Share on other sites

did you try it with _host instead of _caller?

Share this post


Link to post
Share on other sites
did you try it with _host instead of _caller?

Yes... still nothing...

could this be an issue with mando missile getting in the way? Because when I enter the UAV MHQ it adds the "UAV Camera" Action.

Share this post


Link to post
Share on other sites

this is one of my addaction scripts and it works perfectly

_host = _this select 0;
_caller = _this select 1;
_id = _this select 2;
if (not alive _host) exitwith {
hint "Unit Not Alive"; 
_host removeaction _id;
};
_caller sidechat format ["lets go %1, were getting you out of here", name _host];
[_host] join _caller;
_host setcaptive false;
_host enableAI "Move";

_host removeaction _id;

_hostleave = _host addAction ["Leave Hostage", "dta\scripts\ghst_hostleave.sqf", [], 6, true, true, "","alive _target and not pows"];

if yours is not working then something with your initline for starting the script is off or something. this is my script initline

ghst_hostjoin = pow2 addAction [""Rescue Hostage"", ""dta\scripts\ghst_hostjoin.sqf"", [], 6, true, true, """",""alive _target and not pows""];

possible try different prioritys.

Share this post


Link to post
Share on other sites

this is what I have in the triggers "on activation" line.

_uavin = RESCUE2 addAction ["Get In", "getin.sqf"]

I noticed you have double quotes... does that make a difference in the sqf script itself?

Share this post


Link to post
Share on other sites

sorry about the double quotes, did a quick copy from mission.sqm. Single quote is the format you need. Now Rescue2 is the vehicle or your unit? if it is your unit make it the vehicle and put that script initline in the initbox of the vehicle.

hav_uavin = vehname addAction ["Get In", "getin.sqf", [], 6, true, true, "","alive _target"];

;

copy the initline and use that. make sure getin.sqf is in your main missions folder under mydocuments\arma2\missions.

Share this post


Link to post
Share on other sites

It is currently hte unit. Why would I want to give the vehicle the addaction? wouldn't that prevent the unit from being able to get it?

Right now the only thing that doesn't work is the "get out" command.

When my guy walks up, I press "get in" and the script moves him directly into the commander spot, but doesn't add the "get out" command.

So the only part of the script thats not going is the get out portion.

Share this post


Link to post
Share on other sites

if you add the action to the vehicle any unit will get it when they get within range. I have some pretty good experience with this. Look at my script and the wiki and study them. Then look at yours very carefully and look out for typos. dont forget ; after a commandline and check your arma2.rpt file located in local app data. script errors show there. Chances are you have some kind of an error. Possibly with the get out script. What do you have for the get out script?

Share this post


Link to post
Share on other sites

UPDATE:

Ok, so I changed it to where I put the vehicle name in, however, the "Get Out" still doesn't show up, but the "Get In" Stays there and does not going away...

and here is my get out script

(commander UAVMHQ) action ["eject", UAVMHQ]);

Share this post


Link to post
Share on other sites

Unfortunatly still no... I get in just fine, but again, the "Get Out" doesn't show up as an action.

Share this post


Link to post
Share on other sites

well i tried helping you but your not using all the information i am giving you so your on your own now. look at the wiki, and your rpt file. if you dont do that then you fail.

Share this post


Link to post
Share on other sites

I figured out the solution now, my last issue is, Once I get in.. the "Get In" still shows up, and when I get out, both "Get In" and "Get Out" show up, and now all of a sudden I have 5 "Get Ins" and 5 "Get Outs". Its not removing the actions now...

edit: fixed, for some reason I had to have UAVMHQ removeaction uavout; BEFORE (commander UAVMHQ) action ["eject", UAVMHQ]);

Thanks fo rhte help ghost.

Edited by HavocDemon

Share this post


Link to post
Share on other sites

Thanks a lot for explaining the variables passed to the script, Ghost!!

I have been racking my brain trying to get a script to work via an "addaction" on the crate to give the unit that performs the action a specific weapon loadout. I had it working fine for a player by using the line

_this = Player; in my script, but then AI subordinates couldnt use the action.

Now that I defined _caller = _this select 1;

and used _caller removeallweapons; etc etc etc instead of _this removeallweapons and so on, the action works as intended, and any unit that performs the action gets the loadout!

Now, to make scripts for the rest of the available "default loadouts" for players to choose from in my missions....

Share this post


Link to post
Share on other sites

Have the trigger look for a value of a variable and have your SQF/SQS file set, and publicVariable that variable.

That's how I get day/night changes working on all clients, have the trigger actually change the time based on the value set by addAction on the instructor's action menu.

Share this post


Link to post
Share on other sites
Have the trigger look for a value of a variable and have your SQF/SQS file set, and publicVariable that variable.

That's how I get day/night changes working on all clients, have the trigger actually change the time based on the value set by addAction on the instructor's action menu.

I don't understand, sorry. :)

This:

martyr addAction ["Detonate suicide bomb", "boom"]

... doesn't work. 'martyr' is the unit name, 'boom' is the name of the trigger. Surely this can be done in a simple way?

Share this post


Link to post
Share on other sites

The second argument of addAction must be a script. "boom.sqf" and not just boom.

If all you want to do is blow someone up you can just do that in the script, don't need a trigger.

Edited by kylania

Share this post


Link to post
Share on other sites

Well, it's Jeevz' IED script which I attached to one of the players, and in the 'boom' trigger I designate the size of the explosion - i.e. "Huge". So that's why I wanted to refer to the trigger. But I'll try to do it by modifying the .sqs. Would be nice if we could activate a trigger like that though.

Thanks.

Share this post


Link to post
Share on other sites

Ahh ok, no problem:

martyr addAction ["Detonate suicide bomb", "boom.sqf"];

Then boom.sqf would be:

[martyr, "Huge"] exec ied.sqs;

Share this post


Link to post
Share on other sites

Hmm, that doesn't seem to do anything. Nothing happens if I activate the menu item. And I've double checked everything.

What I have right now is this:

  1. A trigger that detects OPFOR present. This trigger attaches trigger 'boom' (the one that executes IED.sqs) to the player called 'martyr' using: boom attachto[martyr,[0,0,0]]
  2. Trigger 'boom' with this in the on act: [martyr, "Huge"] exec "IED.sqs"

If I don't attach trigger 'boom' to the player, it will not follow the player around and the explosion will just go off at the trigger's location.

Maybe it's easier to activate 'boom' by radiocommand Alpha, then add that command to the action menu and change the text of radiocommand Alpha into 'Detonate bomb'?

I dunno... I'll tinker with it again tomorrow, thanks.

Share this post


Link to post
Share on other sites

As I explained, you don't need the trigger at all. In fact in multiplayer you don't want the trigger at all, since if you spawn an explosion via trigger you'll get a huge boom for every client connected...

Create the new script, run it from the addAction, done. Have you tried that? If so, post your mission so we can verify that you had it correct.

Share this post


Link to post
Share on other sites

Hello everyone i need some help.

Ive got a script that adds an action to an object and i want to make it so that it only shows for one specific player.

addAction.sqf

_vehicle = _this select 0;
_side = _this Select 1;

if (_side == EAST) then
{
hqe = _vehicle addAction ["Head Quarters Menu", "module\items\HQ_east_dialog.sqf"];
};

if (_side == WEST) then
{
hqw = _vehicle addAction ["Head Quarters Menu", "module\items\HQ_west_dialog.sqf"];
};

Ive tried this.

addAction.sqf

_vehicle = _this select 0;
_side = _this Select 1;

if (_side == EAST) then
{
 while {true} do 
 {
   if ((squadLeaderEast distance _vehicle) < 3) then
   {
     hqe = _vehicle addAction ["Head Quarters Menu", "module\items\HQ_east_dialog.sqf"];
   };
 };
};

if (_side == WEST) then
{
 while {true} do 
 {
   if ((squadLeaderWest distance _vehicle) < 3) then
   {
     hqw = _vehicle addAction ["Head Quarters Menu", "module\items\HQ_west_dialog.sqf"];
   };
 };
};

But it didnt work.

Can anyone help.

Edited by PartyHead

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  

×