Jump to content
Sign in to follow this  
Chaos

typeOf in array?

Recommended Posts

I have a little problem with asking for typeOf vehicle and checking it to array:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">? typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"] : _bas = basW;

? typeOf _veh in ["Mi17","Mi17_MG","KA50","SU34B","SU34"] : _bas = basE;

This doesn´t works so. confused_o.gif

Share this post


Link to post
Share on other sites

{if (_x=typeOf _veh)then{_bas = basW}} foreach ["Mi17","Mi17_MG","KA50","SU34B","SU34"]

Share this post


Link to post
Share on other sites

If you run that example using exec then it works ok, if you run it with execVM then it returns errors. If you are using execVM and want to stick with it.

Then write it like this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">If (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) Then

      {

      _bas=basW;

      }

      Else

      {

      If (typeOf _veh in  ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) Then

             {

              _bas=basE;

             };

       };

Share this post


Link to post
Share on other sites

Hmm... doesn´t works so:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if (_x=typeOf _veh)then{_bas = basE}} foreach ["Mi17","Mi17_MG","KA50","SU34B","SU34"];

{if (_x=typeOf _veh)then{_bas = basW}} foreach ["AH6","AH1W","A10","AV8B","AV8B2","UH60","UH60MG"];

Bug: aV23oJ69.jpg

crazy_o.gif

Share this post


Link to post
Share on other sites

Use

_x==typeOf _veh

instead of

_x=typeOf _veh

smile_o.gif

Xeno

Share this post


Link to post
Share on other sites

Hmm... its still doesn´t works

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">{if (_x==typeOf _veh)then{_bas = basE;}} foreach ["Mi17","Mi17_MG","KA50","SU34B","SU34"];

{if (_x==typeOf _veh)then{_bas = basW;}} foreach ["AH6","AH1W","A10","AV8B","AV8B2","UH60","UH60MG"]

and

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {if (typeOf _veh in ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) then {_bas=basE;};};

With only following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_bas = basW;

there are no probs crazy_o.gif

My script:

_vtyp = type of vehicle

_crwt = type of crew (1-2-3-4 men)

_wpCR = creation point

_wp1 = waypoint #1

_wp2 = waypoint #2

_wp3 = waypoint #3

_wp4 = waypoint #4

_unit = type of unit ("soldierEpilot")

_hpt = helih (when vehicle is a chopper)

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_vtyp = _this select 0;

_crwt = _this select 1;

_wpCR = _this select 2;

_wp1 = _this select 3;

_wp2 = _this select 4;

_wp3 = _this select 5;

_wp4 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

hintC format ["_vtyp - %1\n_crwt - %2\n_wpCR - %3\n_wp1 - %4\n_wp2 - %5\n_wp3 - %6\n_wp4 - %7\n_unit - %8\n_hpt - %9",_vtyp,_crwt,_wpCR,_wp1,_wp2,_wp3,_wp4,_unit,_hpt];

? _crwt != 1 && _crwt != 2 && _crwt != 3 && _crwt != 4 : hint "falsche Eingabe fuer crewtype. Ueberpruefe die Dokumentation."; exit;

;{if (_x==typeOf _veh)then{_bas = basE;}} foreach ["Mi17","Mi17_MG","KA50","SU34B","SU34"];

;{if (_x==typeOf _veh)then{_bas = basW;}} foreach ["AH6","AH1W","A10","AV8B","AV8B2","UH60","UH60MG"];

if (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {if (typeOf _veh in ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) then {_bas=basE;};};

;_bas = basW;

_wt = 20;

if (typeOf _veh in ["AV8B","AV8B2","SU34","SU34B","A10"]) then {_CreP = _wpCR; _CreP setPos [(getPos _CreP select 0),(getPos _CreP select 1),+4500];} else {_CreP = _hpt; _wt = 30;};

hintC format ["wpCR - %1\nwt - %2\nhpt - %3\nhigh wpcr - %4\nCreP = %5",_wpCR,_wt,_hpt,getPos _wpCR select 2,_CreP];

@ _wpCR distance player > 1000

~2 +random 3

_veh = _vtyp createVehicle getPos _CreP;

hint format says: "_CreP" and "_bas" are scalar, "_veh" (because "_CreP" is scalar) is 0x100...

Share this post


Link to post
Share on other sites
Quote[/b] ]hint format says: _CreP and _bas are scalar, _veh is 0x100...

A couple of things you can change.

For the new variables your creating within the script, you need to defined them first, the same way you did with _wt:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_vtyp = _this select 0;

_crwt = _this select 1;

_wpCR = _this select 2;

_wp1 = _this select 3;

_wp2 = _this select 4;

_wp3 = _this select 5;

_wp4 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

//Initialise local variables

_bas=ObjNull;

_Crep=ObjNull;

_wt = 20;

Do a search on the wiki for scope to get more info.

Also seen as _vtype (type of vehicle) is already being passed as a parameter, you should be able to do this:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_vtyp in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {if (_vtyp in ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) then {_bas=basE;};};

And:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_vtyp in ["AV8B","AV8B2","SU34","SU34B","A10"]) then {_CreP = _wpCR; _CreP setPos [(getPos _CreP select 0),(getPos _CreP select 1),+4500];} else {_CreP = _hpt; _wt = 30;};

Edit: Fixed typo in the variable name _vtyp

Share this post


Link to post
Share on other sites

do it the hard way.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_TV = typeof _veh;

if ((_TV == "Mi17") || (_TV == "MI17_MG") || (_TV == "KA50) || (_TV == "SU34B") || (_TV == "SU34")) then {

_bas = basE};

smile_o.gif

Share this post


Link to post
Share on other sites

Nothing will works - i tested all of them.

Can be, that the problem is because "basE" is a name of group and not name of unit? I have "basegroup unit" for each side placed as officer on the map and wrote in the init line "basE = group this" / "basW = group this". I need the units to create of new pilot units.

Share this post


Link to post
Share on other sites
Quote[/b] ]Can be, that the problem is because "basE" is a name of group and not name of unit?

To be honest, it's almost imossible for me to say. Apart from the fact you're using a mixture of sqs and sqf format commands in the same script. I can't see anything in the code you posted, that relates to creating pilots? Perhaps if you explained exactly what you want to do and how you want to do it.

But the best thing to do when you hit problems, is reduce your script to it's simplest form. Then once you have a basic version working, start adding the extras.

Share this post


Link to post
Share on other sites

Well, here is the script:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

; ["vehicle",crewtype,wpCR,wp1,wp2,wp3,unit_Type] exec "APatrols.sqs";

; ["AV8B2",1,CREPw2,wp1,wp2,wp3."soldierWpilot"] exec "APatrols.sqs";

_vtyp = _this select 0;

_crwt = _this select 1;

_wpCR = _this select 2;

_wp1 = _this select 3;

_wp2 = _this select 4;

_wp3 = _this select 5;

_wp4 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

hintC format ["_vtyp - %1\n_crwt - %2\n_wpCR - %3\n_wp1 - %4\n_wp2 - %5\n_wp3 - %6\n_wp4 - %7\n_unit - %8\n_hpt - %9",_vtyp,_crwt,_wpCR,_wp1,_wp2,_wp3,_wp4,_unit,_hpt];

? _crwt != 1 && _crwt != 2 && _crwt != 3 && _crwt != 4 : hint "falsche Eingabe fuer crewtype. Ueberpruefe die Dokumentation."; exit;

;if (_unit in ["soldierEpilot"]) then {_bas = basE} else {_bas = basW};

;if (typeOf _unit in ["soldierEpilot"]) then {_bas = basE} else {_bas = basW};

;{if (_x==typeOf _veh)then{_bas = basE;}} foreach ["SoldierEPilot"];

;{if (_x==typeOf _veh)then{_bas = basE;}} foreach ["Mi17","Mi17_MG","KA50","SU34B","SU34"];

;{if (_x==typeOf _veh)then{_bas = basW;}} foreach ["AH6","AH1W","A10","AV8B","AV8B2","UH60","UH60MG"];

if (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {if (typeOf _veh in ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) then {_bas=basE;};};

;_bas = basW;

_wt = 20;

if (typeOf _veh in ["AV8B","AV8B2","SU34","SU34B","A10"]) then {_CreP = _wpCR; _CreP setPos [(getPos _CreP select 0),(getPos _CreP select 1),+4500];} else {_CreP = _hpt; _wt = 30;};

hintC format ["wpCR - %1\nwt - %2\nhpt - %3\nhigh wpcr - %4\nCreP = %5",_wpCR,_wt,_hpt,getPos _wpCR select 2,_CreP];

@ _wpCR distance player > 1000

~2 +random 3

_veh = _vtyp createVehicle getPos _CreP;

_veh setDir random 360;

hintC format ["vehicle = %1\ncrewtype = %2\nbasisgroup = %3\nfirst waypoint = %4\ndistance = %5\ncount of crew = %6",_veh,_unit,_bas,_wpCR,_veh distance player,_crwt];

_men1 = _unit;

? _crwt > 1 : _men2 = _unit;

? _crwt > 2 : _men3 = _unit;

? _crwt > 3 : _men4 = _unit;

? _crwt > 4 : _men5 = _unit;

_men1 createUnit [getPos (leader _bas),_bas,"",0.45,"sergeant"];

_ldr = (units _bas) select 1;

[_ldr] join grpNull;

_newgroup = group _ldr;

~.25

? _crwt > 1 : _men2 createUnit [getPos _ldr,_newgroup,"",0.3,"corporal"];

? _crwt > 2 : _men3 createUnit [getPos _ldr,_newgroup,"",0.28,"corporal"];

~1

? _crwt == 1 : leader _newgroup moveindriver _veh;

? _crwt == 2 : leader _newgroup moveindriver _veh; units _newgroup select 1 moveingunner _veh;

? _crwt == 3 : leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh;

But i don´t know about the difference for "sqs commands" and "sqf commands". I think the only differences are ";" on the end and the ".sqf"/".sqs" endings. huh.gif

Now i tested (see about):

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">if (_unit in ["soldierEpilot"]) then {_bas = basE} else {_bas = basW}; but its had not effect. The hint will tell me again "_bas = scalar bool _CreP = scalar" etc.

The command <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_bas = basE; works without problems. crazy_o.gif

Share this post


Link to post
Share on other sites

This worked for me...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_veh = _this select 0;

basW = "Debug string";

if ((typeOf _veh) in ["BMP2","T72"]) then {_bas = basW; hint format ["%1",_bas]};

You need to declare the '_veh' variable before it is used in your condition. Additionally, try using some parentheses and see if that yields you some more positive results.

- dRb

EDIT: Additionally, you have used the SQS tilde wait style instead of the sleep command used in SQF format functions. That could be causing some serious problems...

Share this post


Link to post
Share on other sites

When you're testing a condition on a certain variable, you need to define it before testing it.

That is to say that:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">If (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) Then

     {

     _bas=basW;

     }

     Else

     {

     If (typeOf _veh in  ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) Then

            {

             _bas=basE;

            };

      };

will only work if _bas has been defined before. Therefore:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_bas=0;

If (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) Then

     {

     _bas=basW;

     }

     Else

     {

     If (typeOf _veh in  ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) Then

            {

             _bas=basE;

            };

      }; will work smile_o.gif. I think this may have been the cause of your problem...

Share this post


Link to post
Share on other sites

That is precisely what I was getting at. Strangely, he does not define the "_veh" variable until after its value is checked in a condition statement. Therefore, how could the script check for a particular type of vehicle when the variable being considered has no value at all? In addition, there is no large loop trying to update the private _veh variable, making it impossible for there ever to be a value in the first place.

I do not believe a variable needs to be defined unless it lies within a condition statement. Therefore, I do not see why he would need to define the _bas variable prior to the area where it is defined. My small script sample illustrates that point...

- dRb

EDIT: I felt the need to provide an example...

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// Begin

_boolVariable = true;

if (_boolVariable) then {_stringVariable = "Test"; hint format ["%1",_stringVariable]};

// Even though "_stringVariable" has not been defined prior to this line, it -has- been defined within the statement. Thus, what truly must be defined before hand is "_boolVariable." This should yield no errors and a hint will be displayed in the right hand corner with "Test" as its text.

// End

EDIT2: Upon a few more tests, I have figured out that the scripting engine believes private variables declared within a conditional statement are only known within their own scope. This means that both Igor and myself were correct. You must define all private variables that are used within the script in the outermost scope or else any private variables defined within conditional statements will have values known only to themselves and your script will not function correctly.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// begin

_boolVariable = true;

if (_boolVariable) then {_stringVariable = "Test"};

hint format ["%1",_stringVariable]; //Returns a scalar error

// end

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">// begin

_boolVariable = true;

_stringVariable = "";

if (_boolVariable) then {_stringVariable = "Test"};

hint format ["%1",_stringVariable]; // Returns a successful "Test" hint

// end

EDIT3: A quick rehash of the code given by the OP in SQF

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; ["vehicle",crewtype,wpCR,wp1,wp2,wp3,unit_Type] exec "APatrols.sqs";

; ["AV8B2",1,CREPw2,wp1,wp2,wp3."soldierWpilot"] exec "APatrols.sqs";

_vtyp = _this select 0;

_crwt = _this select 1;

_wpCR = _this select 2;

_wp1 = _this select 3;

_wp2 = _this select 4;

_wp3 = _this select 5;

_wp4 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

hintC format ["_vtyp - %1\n_crwt - %2\n_wpCR - %3\n_wp1 - %4\n_wp2 - %5\n_wp3 - %6\n_wp4 - %7\n_unit - %8\n_hpt - %9",_vtyp,_crwt,_wpCR,_wp1,_wp2,_wp3,_wp4,_unit,_hpt];

if ((_crwt != 1) && (_crwt != 2) && (_crwt != 3) && (_crwt != 4)) exitWith {hint "falsche Eingabe fuer crewtype. Ueberpruefe die Dokumentation."};

hintC format ["wpCR - %1\nwt - %2\nhpt - %3\nhigh wpcr - %4\nCreP = %5",_wpCR,_wt,_hpt,getPos _wpCR select 2,_CreP];

waitUntil {_wpCR distance player > 1000};

sleep (2 + random 3);

_veh = _vtyp createVehicle getPos _CreP;

_veh setDir random 360;

_bas = objNull; // Assuming basW or basE return objects

if (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {if (typeOf _veh in ["Mi17","Mi17_MG","KA50","SU34B","SU34"]) then {_bas=basE;};};

_wt = 20;

if (typeOf _veh in ["AV8B","AV8B2","SU34","SU34B","A10"]) then {_CreP = _wpCR; _CreP setPos [(getPos _CreP select 0),(getPos _CreP select 1),+4500];} else {_CreP = _hpt; _wt = 30;};

hintC format ["vehicle = %1\ncrewtype = %2\nbasisgroup = %3\nfirst waypoint = %4\ndistance = %5\ncount of crew = %6",_veh,_unit,_bas,_wpCR,_veh distance player,_crwt];

_men1 = _unit;

if (_crwt > 1) then {_men2 = _unit};

if (_crwt > 2) then {_men3 = _unit};

if (_crwt > 3) then {_men4 = _unit};

if (_crwt > 4) then {_men5 = _unit};

_men1 createUnit [getPos (leader _bas),_bas,"",0.45,"sergeant"];

_ldr = (units _bas) select 1;

[_ldr] join grpNull;

_newgroup = group _ldr;

sleep 0.25;

if (_crwt > 1) then {_men2 createUnit [getPos _ldr,_newgroup,"",0.3,"corporal"]};

if (_crwt > 2) then {_men3 createUnit [getPos _ldr,_newgroup,"",0.28,"corporal"]};

sleep 1;

if (_crwt == 1) then {leader _newgroup moveindriver _veh};

if (_crwt == 2) then {leader _newgroup moveindriver _veh; units _newgroup select 1 moveingunner _veh};

if (_crwt == 3) then {leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh};

Share this post


Link to post
Share on other sites

Yesss! Thank you all for soo many help. I solved it now too:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">; ["vehicle",crewtype,wpCR,wp1,wp2,wp3,unit_Type] exec "APatrols.sqs";

; ["AV8B2",1,CREPw2,wp1,wp2,wp3."soldierWpilot"] exec "APatrols.sqs";

;

_vtyp = _this select 0;

_crwt = _this select 1;

_wp1 = _this select 2;

_wp2 = _this select 3;

_wp3 = _this select 4;

_wp4 = _this select 5;

_wp5 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

? _crwt != 1 && _crwt != 2 && _crwt != 3 && _crwt != 4 : hint "falsche Eingabe fuer crewtype. Ueberpruefe die Dokumentation."; exit;

waitUntil {_wp1 distance player > 1000};

~1 +random 2

_veh = _vtyp createVehicle getPos _hpt;

_veh setPos [(getPos _hpt select 0),(getPos _hpt select 1),+1];

_veh setDir 270;

_bas = objNull;

~.25

if (typeOf _veh in ["AV8B","AV8B2","UH60","UH60MG","A10","AH6","AH1W"]) then {_bas=basW;} else {_bas=basE;};

~.25

_men1 = _unit;

? _crwt > 1 : _men2 = _unit;

? _crwt > 2 : _men3 = _unit;

? _crwt > 3 : _men4 = _unit;

? _crwt > 4 : _men5 = _unit;

_men1 createUnit [getPos (leader _bas),_bas,"",0.45,"sergeant"];

_ldr = (units _bas) select 1;

[_ldr] join grpNull;

_newgroup = group _ldr;

~.25

? _crwt > 1 : _men2 createUnit [getPos _ldr,_newgroup,"",0.3,"corporal"];

? _crwt > 2 : _men3 createUnit [getPos _ldr,_newgroup,"",0.28,"corporal"];

~.25

? _crwt == 1 : leader _newgroup moveindriver _veh;

? _crwt == 2 : leader _newgroup moveindriver _veh; units _newgroup select 1 moveingunner _veh;

? _crwt == 3 : leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh;

? _crwt == 4 : leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh; units _newgroup select 3 moveincaptain _veh;

;----------------------------------

if (_bas == basE)then{[_veh,FLPe] exec "flee_crw_airH.sqs";}else{[_veh,FLPe] exec "flee_crw_airH.sqs";};

_high = 50;

_veh move [(getPos _veh select 0)-800,(getPos _veh select 2)-500]; _veh flyInHeight 100;

@ speed _veh > 280 || getPos _veh select 2 > 50

if (typeOf _veh in ["AH6","AH1W","Mi17","Mi17_MG","KA50","UH60","UH60MG"])then{_high = 95;} else {_high = 250 +random 250;};

_veh setPos [(getPos _wp1 select 0) -random 50,(getPos _wp1 select 1) +random 50,(getPos _wp1 select 2)+_high];

but i think it is the time to learn more about the new commands for ArmA like "waituntil and so i will use it in my endproduct. The biggest problem was an logic mistake. I have created "_veh" after the "if-then-else" commands. That should be better to ask about "_vtype in array".

Greetings

Chaos

notworthy.gifnotworthy.gifnotworthy.gif

Share this post


Link to post
Share on other sites

Correct! Good job! If you have any further questions or issues that arise, do not hesitate to ask.

- dRb

Share this post


Link to post
Share on other sites

I guess this wasn't the problem here, but it is worth mentioning anyway:

String comparison is case sensitive when using the "in" command!

When using == string comparison is case insensitive.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Example:

"soldierwpilot" in ["soldierWpilot"] //result is FALSE

"soldierwpilot" == "soldierWpilot" //result is TRUE

Also, when using the "switch" command, this is also case sensitive.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

Example:

_var = "soldierwpilot";

switch _var do

{

case "soldierWpilot": {}; //this will never be reached, due to the uppercase "W"

case default {};

};

The safest thing to do when using "in" or "switch" commands and strings, is to first convert all strings to lower case using the "toLower" command.

Share this post


Link to post
Share on other sites

Well, i have actually new problems with the script. If i change it to SQF and exec it normal with exec its would not works. So i executed the function with execVM. After i do it, ArmA is CTD with following info:

aV2mX7Ni.jpg

Sorry, i will not place complete script at this time - short before release. So i will send it to anyone as demomission with PM.

Part of my script as SQF:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

//; ["vehicle",crewtype,wpCR,wp1,wp2,wp3,unit_Type] exec "APatrols.sqf";

//; ["AV8B2",1,CREPw2,wp1,wp2,wp3."soldierWpilot"] exec "APatrols.sqf";

//;

#startALL

if (CHALLAIRPATROLS < CHMINAIRPATROLS;) then {goTo "await";};

_vtyp = _this select 0;

_crwt = _this select 1;

_wp1 = _this select 2;

_wp2 = _this select 3;

_wp3 = _this select 4;

_wp4 = _this select 5;

_wp5 = _this select 6;

_unit = _this select 7;

_hpt = _this select 8;

if (_crwt != 1 && _crwt != 2 && _crwt != 3 && _crwt != 4) then {hint "falsche Eingabe fuer crewtype. Ueberpruefe die Dokumentation."; exitWith;};

waitUntil {_wp1 distance player > 1000};

sleep (2 + random 3);

if (CHALLAIRPATROLS < CHMINAIRPATROLS;) then {goTo "await";};

CHALLAIRPATROLS = CHALLAIRPATROLS -1;

if (CHALLAIRPATROLS < CHMINAIRPATROLS;) then {goTo "await";};

_veh = _vtyp createVehicle getPos _hpt; _veh setPos [(getPos _hpt select 0),(getPos _hpt select 1),+1]; _veh setDir 270;

_bas = objNull;

sleep .25;

if (typeOf _veh in CHAIR_ARRAY_W) then {_bas=basW;} else {_bas=basE;};

sleep .25;

_men1 = _unit;

if (_crwt > 1) then {_men2 = _unit;};

if (_crwt > 2) then {_men3 = _unit;};

if (_crwt > 3) then {_men4 = _unit;};

if (_crwt > 4) then {_men5 = _unit;};

_men1 createUnit [getPos (leader _bas),_bas,"",0.45,"sergeant"];

_ldr = (units _bas) select 1;

[_ldr] join grpNull;

_newgroup = group _ldr;

sleep .25;

if (_crwt > 1) then {_men2 createUnit [getPos _ldr,_newgroup,"",0.3,"corporal"];};

if (_crwt > 2) then {_men3 createUnit [getPos _ldr,_newgroup,"",0.28,"corporal"];};

sleep .25;

if (_crwt == 1) then {leader _newgroup moveindriver _veh;};

if (_crwt == 2) then {leader _newgroup moveindriver _veh; units _newgroup select 1 moveingunner _veh;};

if (_crwt == 3) then {leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh;};

//if (_crwt == 4) then {leader _newgroup moveindriver _veh; units _newgroup select 1 moveincargo _veh; units _newgroup select 2 moveingunner _veh; units _newgroup select 3 moveincaptain _veh;};

//----------------------------------

if (_bas == basE) then {[_veh,FLPe] exec "flee_crw_airH.sqs";}else{[_veh,FLPe] exec "flee_crw_airH.sqs";};

_high = 50;

_veh move [(getPos _veh select 0)-800,(getPos _veh select 2)-500]; _veh flyInHeight 100;

if (speed _veh > 80 || getPos _veh select 2 > 10) then {_a10place = "helihempty" createvehicle [0,0,1]; _a10place setPos getPos _veh;};

if (speed _veh > 150 || getPos _veh select 2 > 10 || !canmove _veh) then {if (typeOf _veh == "A10") then {_veh setPos [(getPos _a10place select 0),(getPos _a10place select 1),(getPos _a10place select 2) +.25];};};

CHINZONE = false;

waitUntil {speed _veh > 280 || (getPos _veh) select 2 > 40};

if (typeOf _veh in CHAIR_ARRAY_HELICOPTER) then {_high = 95;} else {_high = 250 +random 250;};

_veh setPos [(getPos _wp1 select 0) -random 50,(getPos _wp1 select 1) +random 50,(getPos _wp1 select 2)+_high];

The globalarrays and globalvariables are:

CHINZONE = false; this variable will lock all scripts bevore the aircraft is leaving the creation area

CHALLAIRPATROLS = 55; maximal free aircraft slots

CHMINAIRPATROLS = 2; minimal count of aircraft slots

CHAIR_ARRAY_W = ["AV8B","AV8B2","A10","UH60","UH60MG",&a

mp;a

mp;q

uot;AH6","AH1W"]; array for west

CHAIR_ARRAY_E = ["SU34","SU34B","Mi17","Mi17_MG","KA50"]

; array for east

CHAIR_ARRAY_G = [];

CHAIR_ARRAY_C = [];

CHAIR_ARRAY_HELICOPTER = ["AH6","AH1W","Mi17","Mi17_MG","KA50",&q

uot;UH60","UH60MG"]; array for choppers

CHAIR_ARRAY_AIRCRAFT = ["AV8B","AV8B2","A10","SU34","SU34B"]; array for jets

My another problem - when i use the script as SQS is when i will use following:

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">waitUntil {_veh distance _wp5 < (600 +random 350) || !alive _veh || !canmove _veh}; instead of <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">@ _veh distance _wp5 < (600 +random 350) || !alive _veh || !canmove _veh

then it will not works!? Will "waitUntil" have problems with SQS?

Share this post


Link to post
Share on other sites

You cannot mix and match the two formats within the same script or it will not work properly. In the script you have shown us, you have done just that.

* the "#startALL" at the beginning is an erroneous line in SQF

* "goTo" is SQS exclusive

* "exitWith" works like a condition type, not a command (check the biki)

That is all I see at a brief glance.

- dRb

Share this post


Link to post
Share on other sites

Thanks, it was right. The "#" was the issue for the CTDs.

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  

×