Results 1 to 7 of 7
  1. #1
    Banned
    Join Date
    May 2011
    Posts
    917
    Points
    1,182
         User Info     Contact     Gamer ID
    Join Date
    May 2011
    Posts
    917
    Points
    1,182

    Default [Sequel][TUT] How to Script part 6

    Hey guys, took a break yesterday.. Today, I will cover 2 things.. and then post another one about some default action's built in.
    1. If's. if's can be very complicated or very simple. Here is what a if statement looks like
    Code:
    if( self.variable == 12345 )
    Note: There is going to be a lot of reading to do on this. I might not include some info because I forgot. So, if you need help tell me.
    Syntax: So after the if there has to be opening and closing curly braces. Why? Well because there's no semi colon after the closing parentheses in the if.. it keeps going.. Now, if we add curly braces anything inside the curly braces is only ran if the if allows it to by comparing. Here is a syntax:
    Code:
    Example()
    {
           if( self.variable == 1 )
           {
                    self.ThisIsOnlyRanBecauseItsInsideTheCurlyBraces = 1;
           }
    }
    1a. Main idea. If's help compare to a specified value to proceed through the code. Now you can specify a values for multiple things ( Names, True or False, Arrays, Numbers )
    1b. Names. You can compare names with quotation marks
    Code:
    if( self.variable == "like this" )
    So, It's saying if this variable is set to the name of 'like this'
    1c. True or False. You can compare True or False with the name 'true' or 'false' it's as simple as that
    Code:
    if( self.variable == true )
    if( self.variable == false )
    1d. Arrays. Personally, Iv'e never really use this.. So if the coders see something wrong with this please comment on what I need to fix. So, if you haven't read my TUT on Array's you need to do so now. Or you will be confused like hell. So, this is simple not really much explaining.. Like I said above You can compare all 3 and many more to arrays like this
    Code:
    Example()
    {
          if( self.variable[0] == "Name" )
          {
          }
          if( self.variable[0] == 3434 )
          {
          }
          if( self.variable[0] == true )
          {
          }
    }
    1e. Numbers. Easy as pie.. not even going to explain this.
    Code:
    if( self.variable == 20 )
    Okay, now that I think about it I should have said stuff about else if's... When using a variable and comparing to True or False and you want lets say if the variable equals true to put text that says "hi" and if the variable equals false say "fuck you" instead of putting to if's you can use a else if like this:
    Code:
    Example()
    {
           if( self.variable == true )
           {
                  iPrintIn( "Hi" );
           }
           else if( self.variable == false )
           {
                  iPrintIn( "Fuck you" );
           }
    }
    You can do this for all 4 methods I taught you.. Numbers, Arrays, True or False and such.. Now, when using True or false and you want to do what I did up there you don't have to use else if.. You can use just 'else'.. because 'else' represents the other value and anything else.. this as well can be used.. the difference in 'else' and 'else if' is 'else' says "So, if anything else is left after the if that didn't run because the if didn't equal are value do this" <-- hard to explain... 'else if' is like a if statement just for comparing to a different variable... Sorry, guys else and else if is hard to explain so if you need any help just pm me.
    Here's how just 'else' is used:
    Code:
    Example()
    {
          if( self.variable == 20 )
          {
          }
          else 
          {
          }
    }
    You can also use the prefixes ( level, player, ect. ).
    2. Less than and not. now you notice that in if's there is two equal signs.. heres the ones you can use. ( <=, >=, ==, != )
    Means, if the value is less than or equal to proceed with the code.
    Means, if the value is greater than or equal to proceed with the code.
    Means, the value must be equal to the value specified to continue through the code.
    Means, if the value is not equal to proceed with the code.
    I think there's more, but I can't think of them now..
    So that's all thanks.

    0 Not allowed! Not allowed!

  2. #2
    MonsterCat
    Insan3Lik3
    CheeseToast's Avatar
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169
         User Info     Contact     Gamer ID
    Join Date
    Apr 2011
    Location
    Calgary, Alberta, Canada
    Posts
    4,684
    Points
    4,169

    Contact info:

    Youtube Channel: http://www.youtube.com/CheeseToastHax

    Default

    if( self.variable == true )
    if( self.variable == false )
    if(self.variable)
    if(!self.varaible)

    0 Not allowed! Not allowed!
    "It's better to lose an argument/debate then to win. Cause when you lose you grow as a person."
    -CheeseToast

  3. #3
    Banned
    Join Date
    May 2011
    Posts
    917
    Points
    1,182
         User Info     Contact     Gamer ID
    Join Date
    May 2011
    Posts
    917
    Points
    1,182

    Default

    Quote Originally Posted by CheeseToast View Post
    if(self.variable)
    if(!self.varaible)
    Great method! I had never thought of that!

    0 Not allowed! Not allowed!

  4. #4
    Blink 182 Give Me Boners mynameisjosh's Avatar
    Join Date
    Oct 2011
    Posts
    1,377
    Points
    3,107
         User Info     Contact     Gamer ID
    Join Date
    Oct 2011
    Posts
    1,377
    Points
    3,107
    Gamer IDs

    Gamertag: JennaTollzZ PSN ID: OmmNomNomNomNom-

    Default

    Is it possible to do like inbetween's? And thank you for this, I now understand cheesetoast's script he made me

    0 Not allowed! Not allowed!
    Quote Originally Posted by Insane.Dragon View Post
    I fucked a shark once.
    Quote Originally Posted by RED 58 View Post
    i like the sig but i hate russ...
    im seeing conflict here

  5. #5
    Curret n3wbit
    Russ's Avatar
    Join Date
    Aug 2011
    Location
    California
    Posts
    3,193
    Points
    3,398
         User Info     Contact     Gamer ID
    Join Date
    Aug 2011
    Location
    California
    Posts
    3,193
    Points
    3,398
    Gamer IDs

    Gamertag: SSRunts PSN ID: DCCoexist Steam ID: dcrunts

    Default

    ok this helps me understand the structure but doesnt really help actually makin a script i want to do in a game...

    0 Not allowed! Not allowed!

    "Sense is not made like money, sense is had like heart, pride, and integrity."~Russ

  6. #6
    Banned
    Join Date
    May 2011
    Posts
    917
    Points
    1,182
         User Info     Contact     Gamer ID
    Join Date
    May 2011
    Posts
    917
    Points
    1,182

    Default

    Here's some bonus sexy info..(:
    '||' represents or.. so inside an if you have your first variable then it say or then your second variable like this:
    Code:
    if( self.first == 1 || self.second == 0 )
    So, if self.first equals 1 then proceed or if self.second equals 0 proceed so even if first doesn't equal 1 and second equals 0 it will proceed
    '&&' represents and. so, if variable equals a value and the second variable equals the value proceed.. like this:
    Code:
    if( self.one == 1 && self.two == 1 )
    So, one and two variables have to both equal 1.
    There(:

    0 Not allowed! Not allowed!

  7. #7
    Stand em up
    Knock em down.

    Badge

    Join Date
    Oct 2011
    Location
    In Yur Closet
    Posts
    1,578
    Points
    2,825
         User Info     Contact     Gamer ID
    Join Date
    Oct 2011
    Location
    In Yur Closet
    Posts
    1,578
    Points
    2,825
    Gamer IDs

    PSN ID: xRudyCrush Steam ID: rudyypoo

    Default

    These can be hard to understand just because you don't have great grammer.

    "'||' represents or.. so inside an if you have your first variable then it say or then your second variable like this:"

    I have no idea what you just said.

    0 Not allowed! Not allowed!

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT -10. The time now is 08:13 AM.
Powered by vBulletin®
Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.