Jump to content

Photo
- - - - -

if statement


  • Please log in to reply
12 replies to this topic
Thread Starter
GunnDawg09
GunnDawg09

    Sergeant

  • Members
  • 196 posts

  • Joined: 25-June 2009

Posted 11 July 2009 - 09:24 #1

so I was gonna write an if statement in a trigger, or maybe a script file and just call it in the trigger but cant seem to get it to work.

I have a trigger that does "alpha_clear=true" once all of the opfor are dead, but stays "alpha_clear=false" if opfor are still present.

So the trigger I want to make would do: player sidechat "OPFOR still alive!" if alpha_clear=false and: player sidechat "OPFOR have been eliminated!" if alpha_clear=true.

I write a lot in C++ so I figured it would be somwhat the same, but doesnt seem to wanna work. This is what I tried.

if(alpha_clear = false)
{
player sidechat "OPFOR still alive"
}
else if(alpha_clear = true)
{
player sidechat "OPFOR have been eliminated!"
}

Ghost
Ghost

    Gunnery Sergeant

  • Members
  • 584 posts

  • Joined: 09-June 2006
  • LocationCalifornia

Posted 11 July 2009 - 10:02 #2

take a look at this link http://community.bis..._SQF_conversion

Thread Starter
GunnDawg09
GunnDawg09

    Sergeant

  • Members
  • 196 posts

  • Joined: 25-June 2009

Posted 11 July 2009 - 10:11 #3

Thanks ghost I used that as a reference and came up with this... though it says "Missing )"

if (alpha_clear=false) then {player sideChat "Not clear"} else {player sideChat "All Clear"};

I then put it in an .SQF file called "secure.sqf" and in the trigger activation did [] exec "secure.sqf"
and still it doesnt work. it never shows anything in player side chat.

Edited by GunnDawg09, 11 July 2009 - 10:17.


Ghost
Ghost

    Gunnery Sergeant

  • Members
  • 584 posts

  • Joined: 09-June 2006
  • LocationCalifornia

Posted 11 July 2009 - 10:52 #4

Thanks ghost I used that as a reference and came up with this... though it says "Missing )"

if (alpha_clear=false) then {player sideChat "Not clear"} else {player sideChat "All Clear"};

I then put it in an .SQF file called "secure.sqf" and in the trigger activation did [] exec "secure.sqf"
and still it doesnt work. it never shows anything in player side chat.


That looks fine but I like to put ; after each statment i.e.
player sidechat "not clear";

I believe its needed but you would have to double check that.

Thread Starter
GunnDawg09
GunnDawg09

    Sergeant

  • Members
  • 196 posts

  • Joined: 25-June 2009

Posted 11 July 2009 - 10:54 #5

are you suggesting this?

if (alpha_clear=false) then {player sideChat "Not clear";} else {player sideChat "All Clear";};

Ghost
Ghost

    Gunnery Sergeant

  • Members
  • 584 posts

  • Joined: 09-June 2006
  • LocationCalifornia

Posted 11 July 2009 - 10:55 #6

yes. Thats the only thing I see that may be wrong. But then again I am tired and learning scripting myself.

Xeno
Xeno

    ACE Team Leader

  • Members
  • 1814 posts

  • Joined: 20-April 2007

Posted 11 July 2009 - 10:58 #7

if (!alpha_clear) then {player sideChat "Not clear";} else {player sideChat "All Clear";}

Xeno
[SIZE=1][/SIZE]

Ghost
Ghost

    Gunnery Sergeant

  • Members
  • 584 posts

  • Joined: 09-June 2006
  • LocationCalifornia

Posted 11 July 2009 - 11:01 #8

if (!alpha_clear) then {player sideChat "Not clear";} else {player sideChat "All Clear";}

Xeno


dont forget the ; at the end....

Xeno
Xeno

    ACE Team Leader

  • Members
  • 1814 posts

  • Joined: 20-April 2007

Posted 11 July 2009 - 11:05 #9

dont forget the ; at the end....

Not needed in a trigger activation field as long as you don't add code behind it.

Xeno
[SIZE=1][/SIZE]

Ghost
Ghost

    Gunnery Sergeant

  • Members
  • 584 posts

  • Joined: 09-June 2006
  • LocationCalifornia

Posted 11 July 2009 - 11:06 #10

Not needed in a trigger activation field as long as you don't add code behind it.

Xeno


good to know thanks

The_Angry_Canadian
The_Angry_Canadian

    Sergeant

  • Members
  • 112 posts

  • Joined: 10-July 2009

Posted 11 July 2009 - 11:38 #11

so I was gonna write an if statement in a trigger, or maybe a script file and just call it in the trigger but cant seem to get it to work.

I have a trigger that does "alpha_clear=true" once all of the opfor are dead, but stays "alpha_clear=false" if opfor are still present.

So the trigger I want to make would do: player sidechat "OPFOR still alive!" if alpha_clear=false and: player sidechat "OPFOR have been eliminated!" if alpha_clear=true.

I write a lot in C++ so I figured it would be somwhat the same, but doesnt seem to wanna work. This is what I tried.

if(alpha_clear = false)
{
player sidechat "OPFOR still alive"
}
else if(alpha_clear = true)
{
player sidechat "OPFOR have been eliminated!"
}


If you are used to C++, look at that page : http://community.bis...trol_Structures

From what I get, SQS is now deprecated in favor of SQF, which looks a lot more like C++ than the SQS.

Your script then looks like this.

if(!alpha_clear) then
{
   player sidechat "OPFOR still alive";
}
else
{
   player sidechat "OPFOR have been eliminated!";
};

From what I can see, there is NO if, else if structures. You will have to go with nested if, else statements.

Edited by The_Angry_Canadian, 11 July 2009 - 12:32.
To reflect Xeno precision about == vs =


-ASA-ODEN
-ASA-ODEN

    Staff Sergeant

  • Members
  • 396 posts

  • Joined: 10-September 2003

Posted 11 July 2009 - 11:51 #12

I'd suggest Xeno's version with "! boolean", but just for the detail:

alpha_clear = false, this is assigning false to your variable

alpha_clear == false, this is checking if variable is false.

Xeno
Xeno

    ACE Team Leader

  • Members
  • 1814 posts

  • Joined: 20-April 2007

Posted 11 July 2009 - 11:57 #13

ODEN;1358388']
alpha_clear == false, this is checking if variable is false.

Doesn't work in ArmA.

Either a boolean variable is true or false, no need to check against false or true :)
A boolean variable allready mets a condition.

!alpha_clear
or
alpha_clear

Xeno
[SIZE=1][/SIZE]