Jump to content
Sign in to follow this  
evans d [16aa]

NEW TO SCRIPTING: Can someone troubleshoot this for me?

Recommended Posts

Heya,

This is my first proper time trying scripting and I'm getting stuck, naturaly. So, as the title says, can someone please cast their all knowing eye over this code and tell me why it's not working and/or how I can improve it?

Thanks.

_helo = MH60S

//Create the Helo

_helo createUnit [getMarkerPos "heloStart", "this engineOn true";"this flyInHeight 20";"helo1 = this", 1,];



//Give the helo waypoints

_waypoint1 = helo1 addWaypoint [position LZ1, 0];
_waypoint1 setWaypointType "HOLD";

helo1 land "GET IN";

deleteWaypoint [helo1,1];

_waypoint2 = helo1 addWaypoint [position wp2, 0];
_waypoint2 setWaypointType "MOVE";

_waypoint3 = helo1 addWaypoint [position wp3, 0];
_waypoint3 setWaypointType "MOVE";

_waypoint4 = helo1 addWaypoint [position LZ2, 0];
_waypoint4 setWaypointType "HOLD";

helo1 land "GET OUT";

deleteWaypoint [helo1,4];

_waypoint5 = helo1addwaypoint [possition wp5, 0]
_waypoint5 setWaypointType "MOVE";

"LZ1" is a marker, as is "wp2,35", "LZ2" and "heloStart".

My bet is that it's a problem with the init section of the array in the "createUnit" line.

It's being intialised from a trigger with the line "null = execVM "helo1.sqf";"

Thanks again guys,

Bashkire

Share this post


Link to post
Share on other sites

_helo = "MH60S";

//Create the Helo
_grp = createGroup WEST;
_helo createUnit [getMarkerPos "heloStart", _grp, "this engineOn true; this flyInHeight 30; helo1 = this", 1];

//Give the helo waypoints

_waypoint1 = (group helo1) addWaypoint [getMarkerPos "LZ1", 0];
_waypoint1 setWaypointType "MOVE";

helo1 land "GET IN";

// Waituntil all alive units in players group are in the chopper
waitUntil { {_x in helo1 && alive _x} count units group player >= {alive _x} count units group player };

deleteWaypoint [(group helo1),1];

_waypoint2 = (group helo1) addWaypoint [getMarkerPos "wp2", 0];
_waypoint2 setWaypointType "MOVE";

_waypoint3 = (group helo1) addWaypoint [getMarkerPos "wp3", 0];
_waypoint3 setWaypointType "MOVE";

_waypoint4 = (group helo1) addWaypoint [getMarkerPos "wp4", 0];
_waypoint4 setWaypointType "HOLD";

helo1 land "GET OUT";
deleteWaypoint [(group helo1),4];

// Waituntil all alive units in players group are out of the chopper
waitUntil { {_x in helo1 && alive _x} count units group player < 1 };

_waypoint5 = (group helo1) addwaypoint [getMarkerPos "wp5", 0];
_waypoint5 setWaypointType "MOVE";

Ok, that should fix at least some of your problems. If I have missed something obvious let me know :)

Edited by Andy455

Share this post


Link to post
Share on other sites

Hi!

No "all knowing eye" here but I´m pretty sure you´ll have to use 'getMarkerPos' instead of 'position'. The latter only works with objects.

EDIT: Andy455 beat me to it. And put much more effort in it :D

Share this post


Link to post
Share on other sites

yes, provided that your helo1.sqf is in the main mission folder..

Share this post


Link to post
Share on other sites

Yeah, it is. Can I ask you to take a look at the mission itself and see if you can see where it's going wrong?

Share this post


Link to post
Share on other sites

Ok I updated by original post, let me know if that works. Also I advise using the startup param -showScriptErrors as it will put any syntax or misuse of command errors on screen so it makes it much easier ;) an alternative would be to have a look in your RPT file.

Share this post


Link to post
Share on other sites

Just done that and it comes up with a black box at the top of the screen saying:

'...lo1 land "GET IN";
waitUntil { {_x in |#|helo1 && alive _x} count units group pla...'
Error Undefined variable in expression: helo1

It then shows the mission path to the script and tells me that the error is in line 15. I'm going to take a look along with you but I expect that you'll find the solution faster than me.

Share this post


Link to post
Share on other sites

guys, I think this line here can´t work...

_helo createUnit [getMarkerPos "heloStart", _grp, "this engineOn true; this flyInHeight 30; helo1 = this", 1];

I´d try something like this

helo1 = "some_valid_classname" createVehicle getMarkerPos "heloStart";

helo1 engineOn true;

helo1 flyInHeight 30;

@Bashkire: exactly, helo1 isn´t defined, because it wasn´t created. You´ll need a whole other syntax. Try my example, but first get the classname of an adequate helicopter you want to use. I´d try armaholic.com for example.

Edited by CptBBQ

Share this post


Link to post
Share on other sites

That's where I thought the error was in the first place but it didn't flag up that line, only line 15. Blimey this scripting malarky is harder than I imagined. I mean I knew it was hard but this...

EDIT:

@CptBBQ, so what yur saying is get rid of

_helo = "MH60S";

_grp = createGroup WEST;
_helo createUnit [getMarkerPos "heloStart", _grp, "this engineOn true; this flyInHeight 30; helo1 = this", 1];

And replace it with

helo1 = "MH60S" createVehicle getMarkerPos "heloStart"; 
helo1 engineOn true; 
helo1 flyInHeight 30; 

By the way, I have checked, MH60S is the classname for the chopper with the same designation.

Edited by Bashkire

Share this post


Link to post
Share on other sites

I´ve corrected some other issues. Not use if it works now, but it should get you much further now.

//Create the Helo

_grp = createGroup WEST;

helo1 = "MH60S" createVehicle getMarkerPos "heloStart";

helo1Pilot = _grp createUnit ["USMC_Soldier_Pilot", getMarkerPos "heloStart", [], 10, "FORM"];

helo1Pilot moveInDriver helo1;

//Give the helo waypoints

_waypoint1 = _grp addWaypoint [getMarkerPos "LZ1", 0];

_waypoint1 setWaypointType "HOLD";

helo1 land "GET IN";

// Waituntil all alive units in players group are in the chopper

waitUntil { {_x in helo1 && alive _x} count units group player >= {alive _x} count units group player };

helo1 flyInHeight 30;

helo1 engineOn true;

deleteWaypoint [_grp,1];

_waypoint2 = _grp addWaypoint [getMarkerPos "wp2", 0];

_waypoint2 setWaypointType "MOVE";

_waypoint3 = _grp addWaypoint [getMarkerPos "wp3", 0];

_waypoint3 setWaypointType "MOVE";

_waypoint4 = _grp addWaypoint [getMarkerPos "wp4", 0];

_waypoint4 setWaypointType "HOLD";

helo1 land "GET OUT";

deleteWaypoint [_grp,4];

// Waituntil all alive units in players group are out of the chopper

waitUntil { {_x in helo1 && alive _x} count units group player < 1 };

_waypoint5 = _grp addwaypoint [getMarkerPos "wp5", 0];

_waypoint5 setWaypointType "MOVE";

Share this post


Link to post
Share on other sites

Just tinking with the script. I probaly should have said that "heloStart" was over water so I've got to find the right height to spawn it at so the engines have time to spool up and it doesn't nosedive into the sea.

Share this post


Link to post
Share on other sites
Just tinking with the script. I probaly should have said that "heloStart" was over water so I've got to find the right height to spawn it at so the engines have time to spool up and it doesn't nosedive into the sea.

Create the unit as FLYING... then you wont have an issue :P

Line from one of my scripts: createvehicle ["MH60S", start, [], 150, "FLY"];

Try changing your top 4 lines to:

_grp = createGroup WEST;

helo1 = createvehicle ["MH60S", getMarkerPos "heloStart", [], 150, "FLY"];

helo1Pilot = _grp createUnit ["USMC_Soldier_Pilot", getMarkerPos "heloStart", [], 10, "FORM"];

helo1Pilot moveInDriver helo1;

If you're using this on a dedicated server and calling from a trigger, make sure you call using the trigger condition this && isServer and add if (!isServer) exitwith {}; to the top of your script else you'll get one group PER client and end up with a nightmare.

Edited by rexehuk

Share this post


Link to post
Share on other sites

So I should change this

helo1 = "MH60S" createVehicle getMarkerPos "heloStart";

to

helo1 = createvehicle ["MH60S", start, [], 110, "FLY"];

---------- Post added at 03:26 PM ---------- Previous post was at 03:14 PM ----------

AH HA! It spawns! Now I just need to get it flying towards the waypoints.

Share this post


Link to post
Share on other sites

This is a script from CREOBELLUM - http://creobellum.org

Should have most of what you want to do in it

//////////////////////////////////////////////////////////////////

// Function file for ARMA2

// Created by: (AEF)Odin [2CAV]

// Created: 2009/12/29

// Contact: http://creobellum.org

// Purpose: Call in US Airsupport

// Usage: Create four invisable Heli-Pads and name them ===>

//

// start

// target

// egress

// doitagain

//

// Place these in a staight line in the order they have been written. doitagain represents the cycle Waypoint

//

// Call the script either by a radio trigger or by a trigger with your conditions and type this in the On Act box

// crB = execVM "crB_scripts\crB_jago.sqf"

//

///////////////////////////////////////////////////////////////////

if (!isServer) exitwith {};

publicVariable msgOne;

msgOne = true;

_mark = "SmokeShellRed" Createvehicle [(getPos target select 0),(getPos target select 1),(getPos target select 2)+2];

_ma2 = creategroup west;

AirSupport = createvehicle ["A10_US_EP1", start, [], 110, "FLY"];

//AirSupport = createvehicle ["AV8B2", start, [], 110, "FLY"];

//AirSupport = createvehicle ["AH64D_EP1", start, [], 110, "FLY"];

//AirSupport = createvehicle ["MH60S", start, [], 110, "FLY"];

_m1 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

_m1 setRank "COLONEL";

_m2 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

//_m3 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

_m1 moveInDriver AirSupport;

_m2 moveInGunner AirSupport; // Uncomment for Gunner ==> AH64D

//_m3 MoveInTurret [AirSupport,[1]]; // Uncomment for 2nd Gunner ==> MH60S

sleep 3;

AirSupport1 = createvehicle ["A10_US_EP1", start, [], 110, "FLY"];

//AirSupport1 = createvehicle ["AV8B2", start, [], 110, "FLY"];

//AirSupport1 = createvehicle ["AH64D_EP1", start, [], 110, "FLY"];

//AirSupport1 = createvehicle ["MH60S", start, [], 110, "FLY"];

_m4 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

//_m5 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

//_m6 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

_m4 moveInDriver AirSupport1;

//_m5 moveInGunner AirSupport1; // Uncomment for Gunner ==> AH64D

//_m6 MoveInTurret [AirSupport1,[1]]; // Uncomment for 2nd Gunner ==> MH60S

sleep 3;

AirSupport2 = createvehicle ["A10_US_EP1", start, [], 110, "FLY"];

//AirSupport2 = createvehicle ["AV8B2", start, [], 110, "FLY"];

//AirSupport2 = createvehicle ["AH64D_EP1", start, [], 110, "FLY"];

//AirSupport2 = createvehicle ["MH60S", start, [], 110, "FLY"];

_m7 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

//_m8 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

//_m9 = _ma2 createUnit ["USMC_Soldier_Pilot", position start, [], 0, "form"];

_m7 moveInDriver AirSupport2;

//_m8 moveInGunner AirSupport2; // Uncomment for Gunner ==> AH64D

//_m9 MoveInTurret [AirSupport2,[1]]; // Uncomment for 2nd Gunner ==> MH60S

_wp = _ma2 addWaypoint [position start, 0];

_wp1 = _ma2 addWaypoint [position target, 0];

_wp2 = _ma2 addWaypoint [position egress, 0];

_wp3 = _ma2 addWaypoint [position doitagain, 0];

[_ma2, 1] setWaypointType "Move";

[_ma2, 1] setWaypointSpeed "FULL";

[_ma2, 1] setWaypointBehaviour "CARELESS";

[_ma2, 1] setWaypointStatements ["true", "AirSupport flyInHeight 110;"];

[_ma2, 2] setWaypointType "SAD";

[_ma2, 2] setWaypointSpeed "Move";

[_ma2, 2] setWaypointBehaviour "CARELESS";

[_ma2, 2] setWaypointStatements ["true", "AirSupport flyInHeight 110;"];

[_ma2, 3] setWaypointType "MOVE";

[_ma2, 3] setWaypointSpeed "FULL";

[_ma2, 3] setWaypointBehaviour "CARELESS";

[_ma2, 3] setWaypointStatements ["true", "AirSupport flyInHeight 110;this setFuel 1"];

[_ma2, 4] setWaypointType "CYCLE";

[_ma2, 4] setWaypointSpeed "FULL";

[_ma2, 4] setWaypointBehaviour "CARELESS";

[_ma2, 4] setWaypointStatements ["true", "AirSupport flyInHeight 110;"];

sleep 180;

Boldened the WAYPOINT section for you, read it and see if you can understand it :). For your purposes if you're using MARKERS, you'll need to use getMarkerPos "markername" instead of Position start etc Happy editing!

Edited by rexehuk

Share this post


Link to post
Share on other sites

*Head explodes*

Nope sorry, I have no idea how to cange that for my means. Can I ask you to rewrite and tell me what you did for my waypoint section?

//Create the Helo
_grp = createGroup WEST;
helo1 = createvehicle ["MH60S", getMarkerPos "heloStart", [], 150, "FLY"];
helo1Pilot = _grp createUnit ["USMC_Soldier_Pilot", getMarkerPos "heloStart", [], 10, "FORM"];
helo1Pilot moveInDriver helo1;


//Give the helo waypoints

_waypoint1 = _grp addWaypoint [getMarkerPos "LZ1", 0];
_waypoint1 setWaypointType "HOLD";

helo1 land "GET IN";

// Waituntil all alive units in players group are in the chopper
waitUntil { {_x in helo1 && alive _x} count units group player >= {alive _x} count units group player };
helo1 flyInHeight 30;
helo1 engineOn true; 

deleteWaypoint [_grp,1];

_waypoint2 = _grp addWaypoint [getMarkerPos "wp2", 0];
_waypoint2 setWaypointType "MOVE";

_waypoint3 = _grp addWaypoint [getMarkerPos "wp3", 0];
_waypoint3 setWaypointType "MOVE";

_waypoint4 = _grp addWaypoint [getMarkerPos "LZ2", 0];
_waypoint4 setWaypointType "HOLD";

helo1 land "GET OUT";
deleteWaypoint [_grp,4];

// Waituntil all alive units in players group are out of the chopper
waitUntil { {_x in helo1 && alive _x} count units group player < 1 };

_waypoint5 = _grp addwaypoint [getMarkerPos "wp5", 0];
_waypoint5 setWaypointType "MOVE";

You have no idea how much I want this to work and I have my CO on my back trying to get me to complete this mission. It is going to be multiplayer so I'm going to add your code in later. I assume it goes at the top and bottom repectivly.

Share this post


Link to post
Share on other sites

Is anyone able to help? Sorry if I'm being impatient but I'd really like to get this done. The copper doesn't follow the waypoints. It spawns and just hovers there. I can make it move with the doMove command but then it doesn't land... or do anything else.

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  

×