Jump to content

Recommended Posts

How do i make this work if hvtarray is equal to 1

CODE:
hvtarray = selectRandom [1,2];

if (hvtarray isEqualTo 1) then
{
hint "task1";
hvt1 = "O_officer_F" createVehicle getMarkerPos "hvt1";
"O_Soldier_AR_F" createVehicle getMarkerPos "hvt1";
"O_Soldier_AR_F" createVehicle getMarkerPos "hvt1";
//TASK
thvt1 = player createSimpleTask ["Kill HVT"];
thvt1 setSimpleTaskDestination (getMarkerPos "hvt1");
thvt1 settaskstate "Created";
}
else {//nothing};

if (hvtarray isEqualTo 2) then
{
hint "task2";
hvt2 = "O_officer_F" createVehicle getMarkerPos "hvt2";
"O_Soldier_AR_F" createVehicle getMarkerPos "hvt2";
"O_Soldier_AR_F" createVehicle getMarkerPos "hvt2";
//TASK
thvt2 = player createSimpleTask ["Kill HVT"];
thvt2 setSimpleTaskDestination (getMarkerPos "hvt2");
thvt2 settaskstate "Created";
}
else {//nothing};

hvtarray = 0;
-----------------

The hint doesnt show up. i tried using == instead of isEqualTo but no luck.

Share this post


Link to post
Share on other sites
else {//nothing};

This breaks things. You're commenting out the end of the ELSE segment. So remove the '//nothing', or the whole else part if you don't intend to put anything in there.

Share this post


Link to post
Share on other sites
1 minute ago, Greenfist said:

else {//nothing};

This breaks things. You're commenting out the end of the ELSE segment. So remove the '//nothing', or the whole else part if you don't intend to put anything in there.

is it that simple?... different language of coding.

Share this post


Link to post
Share on other sites
9 minutes ago, Greenfist said:

else {//nothing};

This breaks things. You're commenting out the end of the ELSE segment. So remove the '//nothing', or the whole else part if you don't intend to put anything in there.

just got it working, how do i make the units become simulated?

Share this post


Link to post
Share on other sites
32 minutes ago, -NotGeorge- said:

just got it working, how do i make the units become simulated?

You try to create a unit with the createVehicle command.

Anything ring a bell?

 

Cheers

Share this post


Link to post
Share on other sites

_asd = selectRandom [1,2];

 

if (_asd == 1) then 
{
hint "Result 1";
} else {};

 

if (_asd == 2) then 
{
hint "Result 2";
} else {};

Share this post


Link to post
Share on other sites
4 hours ago, -NotGeorge- said:

different language of coding


Huh? Even generic highlighter shows you that // comments out everything until the end of line, including closing curly bracket. Out of curiousity, what language would allow you to do this and get away with it?

Share this post


Link to post
Share on other sites

What about this code optimization:

Call {

  if (hvtarray isEqualTo 1) exitWith {< code1 >};

  < code 2 >;

};

I never understood the usage of "empty" else { } anyway!

Share this post


Link to post
Share on other sites

Empty else statements are actually a good coding practice. I have run into a couple of obscure coding languages(please don't ask what they were, it's been so long since I have worked with them i don't remember) that freak out if you don't have an actual else statement included.

Share this post


Link to post
Share on other sites
7 minutes ago, Squirtman said:

Empty else statements are actually a good coding practice. I have run into a couple of obscure coding languages(please don't ask what they were, it's been so long since I have worked with them i don't remember) that freak out if you don't have an actual else statement included.

 

Using empty else statements is also a very good indication to others that you have no clue what you are doing.

  • Like 5

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

×