Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Multiple conditions in one "if" statement
Kyle Offline
Posting Freak

Posts: 911
Threads: 36
Joined: Sep 2010
Reputation: 7
#2
RE: Multiple conditions in one "if" statement

Congratz! Well, first off, you can simply try this:

void Function(string &in asEntity, int alState)
{
     if (GetLocalVarInt("Var01") == 1)
     {
          //Do stuff
          return;
     }
     else if (GetLocalVarInt("Var01") == 2)
     {
          //Do stuff
          return;
     }
}

There are many ways to do it.

void Function(string &in asEntity, int alState)
{
     if (GetLocalVarInt("Var01") == 1)
     {
          //Do stuff
          return;
     }
     else
     {
          //Do stuff
          return;
     }
}

The "&&" (and) and "||" (or) work perfectly the same way as of C++ and Angelscript. It's just that you weren't using it correctly. You can try this if the local variable "var01" equals 1 and the local variable "var02" equals 1.

void Function(string &in asEntity, int alState)
{
     if ((GetLocalVarInt("Var01") == 1) && (GetLocalVarInt("Var02") == 1))
     {
          //Do stuff
          return;
     }
}

And also to add a little note here, the "else if" checks to see to check something to see if it's true, if the first part, the "if", is false. To be honest, this is intermediate scripting. Tongue

(This post was last modified: 07-20-2011, 03:37 PM by Kyle.)
07-20-2011, 03:31 PM
Find


Messages In This Thread
RE: Multiple conditions in one "if" statement - by Kyle - 07-20-2011, 03:31 PM



Users browsing this thread: 1 Guest(s)