Jump to content
Sign in to follow this  
splatsh

all new to this, help with script.

Recommended Posts

I have read some, and I am trying to create some stuff.

Here I am creating a chopper, and two pilots, and make them to get in.

and this works for me.

Pilots = CreateGroup East;
_vcl_new = "Mi17_rockets_RU" createVehicle [(position start_heli select 0)+1, (position start_heli select 1)+1,0];
_vcl_new setVehicleVarName "heli";
_crewPilot0 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];
_crewPilot1 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];
_crewPilot0 moveinDriver _vcl_new;
_crewPilot1 moveinCargo _vcl_new;

Next step is to create a squad.

This also works fine for me.

GroupSquad1 = CreateGroup East;
_leader = GroupSquad1 createUnit ["RU_Soldier_SL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_MG", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_Marksman", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AR", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_GL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_leader = leader GroupSquad1;

{_x moveInCargo _vcl_new} foreach units _leader;

Now I will create some move for the chopper.

This also works fine for me.

_vcl_new move (position flyTo1);
@_vcl_new distance flyTo1 < 130;
_vcl_new move (position eject);
@_vcl_new distance eject < 130;

And now we are at the part where I get error.

I want to eject my squad, I have this code for that

_group = _this select 0;
_vehicle = _this select 1;

if ( (typename _group != "GROUP") or (typename _vehicle != "OBJECT") ) exitwith {
hintSilent "Invalid Parameters parsed";
};

sleep 1;

{
unassignvehicle _x;
_x action ["EJECT", _vehicle];
sleep 0.5;
} foreach units _group;

Now, I have try some out, like:

_group = _leader;
_vehicle = _vcl_new;

And

_group = GroupSquad1;
_vehicle = heli;

At the top of the eject code, instead of:

_group = _this select 0;
_vehicle = _this select 1;

But I cant get it to work, my men will not eject. why?

How can I do so they will eject?

And please, its my first time here, and my first code and script of this game.

I have no experience of arma or arma2 at all. and not there codes and so on.

I was learning from this forum and from this site tonight: http://community.bistudio.com/wiki/Category:Scripting_Commands_ArmA2

thanks

Share this post


Link to post
Share on other sites

Why are you doing all of that via scripts and not the editor itself?

As for ejecting, search for eject there's been plenty of threads about it.

Share this post


Link to post
Share on other sites

I think you dont passed the names of the squad and the heli as parameter to the script.

_group = _this select 0;
_vehicle = _this select 1;

Means that the 1 param, will be stored in _group and the second param in _vehicle.

If you exec the script, you must write this:

dumvar = [groupname,yourchopper] execVM "eject.sqf";

This:

_group = _leader;
_vehicle = _vcl_new;

wont work because a var with the "_" prefix is local in each script. In a new script, this _VCL_new and _leader is empty.

If you have the eject code in the same file, you just need this:

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5;
} foreach units GroupSquad1;

You dont need the "if"-thing because you KNOW that the params are correct (your created them^^)

Share this post


Link to post
Share on other sites
Why are you doing all of that via scripts and not the editor itself?

As for ejecting, search for eject there's been plenty of threads about it.

please dont answer me again... you dont think I have search, there is 2 pages with hit on searsh of the word eject, I was doing this over and over and over for 5 hours last night, and testing all things out, and searched this forum and tested things out. Then I desided to register and write all my code I got so far and ask in this forum...

---------- Post added at 10:47 AM ---------- Previous post was at 10:42 AM ----------

I think you dont passed the names of the squad and the heli as parameter to the script.

_group = _this select 0;
_vehicle = _this select 1;

Means that the 1 param, will be stored in _group and the second param in _vehicle.

If you exec the script, you must write this:

dumvar = [groupname,yourchopper] execVM "eject.sqf";

This:

_group = _leader;
_vehicle = _vcl_new;

wont work because a var with the "_" prefix is local in each script. In a new script, this _VCL_new and _leader is empty.

If you have the eject code in the same file, you just need this:

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5;
} foreach units GroupSquad1;

You dont need the "if"-thing because you KNOW that the params are correct (your created them^^)

Well, I have not created them at all, I have read this forum and copy and paste, and try thing out, to learn some things... so none of these code are my.

and thanks for this answer

"wont work because a var with the "_" prefix is local in each script. In a new script, this _VCL_new and _leader is empty."

Now I know that. But I have all code on the same page/file... strange?

like this, this is my entire code and script:

// heli_eject.sqf

Pilots = CreateGroup East;
_vcl_new = "Mi17_rockets_RU" createVehicle [(position start_heli select 0)+1, (position start_heli select 1)+1,0];
_vcl_new setVehicleVarName "heli";
_crewPilot0 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];
_crewPilot1 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];
_crewPilot0 moveinDriver _vcl_new;
_crewPilot1 moveinCargo _vcl_new;



GroupSquad1 = CreateGroup East;
_leader = GroupSquad1 createUnit ["RU_Soldier_SL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_MG", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_Marksman", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AR", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_GL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_leader = leader GroupSquad1;

{_x moveInCargo _vcl_new} foreach units _leader;

sleep 1;


_vcl_new move (position flyTo1);
@_vcl_new distance flyTo1 < 130;
_vcl_new move (position eject);
@_vcl_new distance eject < 130;

_group = _leader;
_vehicle = _vcl_new;

if ( (typename _group != "GROUP") or (typename _vehicle != "OBJECT") ) exitwith {
hintSilent "Invalid Parameters parsed";
};

sleep 1;

{
unassignvehicle _x;
_x action ["EJECT", _vehicle];
sleep 0.5;
} foreach units _group;

you see, I have all on the same page... but it still not working

Done some update on the code...

{_x action ["EJECT", _vcl_new];
sleep 0.5;
} 	foreach units _leader;
{unassignvehicle _x} foreach units _leader;

now, that code will get down the chopper and let my squad out.. so unassignvehicle is working OK =)

Now, can you help me with this code and get it to work fine.

{_x action ["EJECT", _vcl_new];
sleep 0.5;
} 	foreach units _leader;

Edited by splatsh

Share this post


Link to post
Share on other sites

Looks quite correct...

have a look in your Arma.rpt (the debug file)

Its located in c:\user\yourname\appdata(invisible)\local\arma2\arma.rpt

Share this post


Link to post
Share on other sites

I use a similar script, trying to get a helicopter fly to a waypoint (this works) and land on a empty H and wait until "soldier1" and "soldier2" are inside and fly to another waypoint (that dosent work).

How do you get an spawned helicopter to land on a emty H and wait for "soldier1" and "soldier2" before he flys to another waypoint ?

Share this post


Link to post
Share on other sites

I have finaly got it to work ok.

Maybe someone could optimize this, but it all works fine here now.

I dont know if it work in MP or so.

I got it working in editor/preview.

// heli_eject.sqf ****************

// Create Chopper and crew
Pilots = CreateGroup East;
_vcl_new = "Mi17_rockets_RU" createVehicle [(position start_heli select 0)+1, (position start_heli select 1)+1,0];
_vcl_new setVehicleVarName "heli";
_crewPilot0 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];
_crewPilot1 = Pilots createUnit ["RU_Soldier_Crew", [(position start_pilot) select 0,(position start_pilot) select 1,0], [], 3, "FORM"];

// Move crew into chopper
_crewPilot0 moveinDriver _vcl_new;
_crewPilot1 moveinCargo _vcl_new;


// Create Squad
GroupSquad1 = CreateGroup East;
_leader = GroupSquad1 createUnit ["RU_Soldier_SL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_MG", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_Marksman", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_LAT", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_AR", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_GL", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];
_unit = GroupSquad1 createUnit ["RU_Soldier_Medic", [(position start_soldier) select 0,(position start_soldier) select 1,0], [], 3, "FORM"];

// Make leader
_leader = leader GroupSquad1;

// Move squad inside chopper
{_x moveInCargo _vcl_new} foreach units _leader;


// Create waypoint for chopper
_waypoint0 = Pilots addwaypoint[position eject1,10];
_vcl_new flyinHeight 150;
_waypoint0 setWaypointSpeed "FULL"
_waypoint0 setwaypointtype "MOVE";

_waypoint0 = Pilots addwaypoint[position heli_stop,10];
_waypoint0 setWaypointSpeed "FULL"
_waypoint0 setwaypointtype "MOVE";

@_vcl_new distance eject1 < 200;

// Make squad to eject the chopper
{_x action ["EJECT", _vcl_new]} foreach units _leader;
{unassignvehicle _x} foreach units _leader;

// Create waypoint for squad
_waypoint1 = GroupSquad1 addwaypoint[position eject1,500];
_waypoint1 setWaypointSpeed "LIMITED"
_waypoint1 setwaypointtype "SAD";

// Create waypoint 2 for squad
_waypoint2 = GroupSquad1 addwaypoint[position eject1,10];
_waypoint2 setWaypointSpeed "LIMITED"
_waypoint2 setwaypointtype "DISMISS";

// Land the chopper
@_vcl_new distance heli_stop < 200;
{unassignvehicle _x} foreach units _crewPilot0;

// Wait 60 seconds
~60
// Delete Chopper and crew
deleteVehicle _vcl_new;
deleteVehicle _crewPilot0;
deleteVehicle _crewPilot1;
EXIT

got a trigger to set all of.

And the best is that I can use the same trigger and the same code over and over.

Share this post


Link to post
Share on other sites

This work:

{unassignvehicle _x} foreach units _leader;
{_x action ["EJECT", _vcl_new]} foreach units _leader;

This NOT work:

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5
} foreach units _leader;

Why?

Share this post


Link to post
Share on other sites

Cause you forgot a semicolon behind sleep 0.5 ^^;

The version above is wrong too... behind every line must be a ";" (but this dont seems to produce errors, buts its quite wrong);

This is correct:

{unassignvehicle _x;} foreach units _leader;
{_x action ["EJECT", _vcl_new];} foreach units _leader; 

or

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5;
} foreach units _leader; 

Edited by NeoArmageddon

Share this post


Link to post
Share on other sites
Cause you forgot a semicolon behind sleep 0.5 ^^;

The version above is wrong too... behind every line must be a ";" (but this dont seems to produce errors, buts its quite wrong);

This is correct:

{unassignvehicle _x;} foreach units _leader;
{_x action ["EJECT", _vcl_new];} foreach units _leader; 

or

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5;
} foreach units _leader; 

Thanks, but the second one is not working, they dont eject =/

Working

{unassignvehicle _x;} foreach units _leader;
{_x action ["EJECT", _vcl_new];} foreach units _leader;

NOT working

{
unassignvehicle _x;
_x action ["EJECT", _vcl_new];
sleep 0.5;
} foreach units _leader;

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  

×