Page 2 of 4 FirstFirst 1 2 3 4 LastLast
Results 11 to 20 of 40

Thread: To learn how to script.

  1. #11
    Veteran Ek CM Bolivar's Avatar
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    423
    Wow, complicated but getting it.
    How to contact me?

    In-game name currently: ZombiEk" Ciprioni
    Current gang owned: Mayhem
    Skype: ek_graal
    Facebook: Shannon Gallagher
    Email: [email protected]
    Push notifications: enabled

    Ask me any questions/concerns!

  2. #12
    Veteran Ek CM Bolivar's Avatar
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    423
    Can we start easy?
    How to contact me?

    In-game name currently: ZombiEk" Ciprioni
    Current gang owned: Mayhem
    Skype: ek_graal
    Facebook: Shannon Gallagher
    Email: [email protected]
    Push notifications: enabled

    Ask me any questions/concerns!

  3. #13
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    Oh yes poorface, I think we stopped at loops...
    They're pretty easy to learn, I guess I can include them in my next tutorial, but here's an overview.
    A loop can be either infinite, or specific, and the only way to stop a loop is to put 'break;' or 'return;' if it is infinite.
    Lot's of ways to have loops on Graal.
    I'm going to teach you the for(); loop today. Let me show you how it works correctly.
    PHP Code:
    function onCreated() {
      for (
    06i++) {
        echo(
    i);
      }

    what this will echo is:
    0
    1
    2
    3
    4
    5
    So how does this work? You have three arguments to have in a for() loop.
    PHP Code:
    for (0// This will be read once at the beginning
          
    5// this will be checked everytime
          
    += // or whatever you want to change every time the loop starts (WARNING, this does not take a semi colomn
          
    ) {
        echo(
    i);

    You can replace all of the above this way:
    PHP Code:
    function onCreated() {
      
      
    0;
      
      if (
    5) break;

      echo(
    i);

      
    += 1// or i++; whatever

      
    if (5) break;

      echo(
    i);

      
    +=1;

      if (
    5) break;

      echo(
    i);

      
    += 1;

      if (
    5) break;

      echo(
    i);

      
    += 1;

      if (
    5) break;

      echo(
    i);

      
    += 1;
      
    // etc

    -Johnaudi

  4. #14
    Veteran Ek CM Bolivar's Avatar
    Join Date
    Jul 2013
    Location
    Australia
    Posts
    423
    Wow. So it is like counting, or continous things it says?
    How to contact me?

    In-game name currently: ZombiEk" Ciprioni
    Current gang owned: Mayhem
    Skype: ek_graal
    Facebook: Shannon Gallagher
    Email: [email protected]
    Push notifications: enabled

    Ask me any questions/concerns!

  5. #15
    Veteran Striker's Avatar
    Join Date
    Jul 2013
    Location
    Britian
    Posts
    283
    well, I understand now what "break;" does, I don't understand what not make them like a line like so:
    PHP Code:
    function onActionServerSide(plthis.lucky) {
      for (
    pl players) {
        if (
    pl.level == "era_lucky-grab.nw") {
          
    pl.setlevel2("era_luck-grab.nw"3030);
          
    triggerclient("gui"namepl)
        }  
          if (
    this.lucky == true)
           
    pl.setlevel2("era_lucky-grab.nw"3040); 
         } 
            
    pl.setlevel2("era_start.nw"3030);
      }
    }
    function 
    onCreated() {
      for (
    this.num 0this.num 5this.num--) {
      }
    }

    //#CLIENTSIDE
    function onPlayerChats() {
      
    this.staff "Events Team";
      if (
    player.guild in this.staff && player.chat == "down") {
        
    triggerserver("gui"nameNULL);
      }
    }
    function 
    onActionClientSide(pl) {
      
    this.lucky "Yay I'm luck!";
      if (
    player.guild in this.staff && player.chat == ":timer") {
        
    player.chat "kicking in: " this.num;
        if (
    player.this.staff.chat == "0")
          
    sleep(3);
          if (
    pl.level == "era_lucky-grab.nw" && player.chat == "Yay I'm lucky!")
            
    triggerserver("gui"nameplthis.lucky)
          }
            if (
    player.chat != this.lucky) {
              
    triggerserver("gui"nameNULL)
          }
        }
      }

    Last edited by Striker; 07-16-2013 at 02:18 PM. Reason: added extras
    Striker*
    -Have any question, concerns or problems?
    Message me on forums, click on the link if you need help: http://era-go.com/forum/member.php?410-Striker
    Need help on iEra P.M my nick name is Striker*
    -Need further help? My email is:[email protected]
    ENjOY PLAYING IERA!!!!!
    -Gani Artist

  6. #16
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    Quote Originally Posted by Striker View Post
    well, I understand now what "break;" does, I don't understand what not make them like a line like so:

    function onCreated() {
    for (this.num = 0; this.num < 5; this.num--) {
    }
    }

    //#CLIENTSIDE
    function onPlayerChats() {
    if (player.chat == ":timer") {
    player.chat = this.num;
    }
    }
    You keep forgetting that the variables in serverside ARE NOT THE SAME on clientside x.x
    And also, the onCreated() function is the first function that gets called...
    -Johnaudi

  7. #17
    Veteran Striker's Avatar
    Join Date
    Jul 2013
    Location
    Britian
    Posts
    283
    Quote Originally Posted by John View Post
    You keep forgetting that the variables in serverside ARE NOT THE SAME on clientside x.x
    And also, the onCreated() function is the first function that gets called...
    What do you mean by they aren't the same, isn't this. go through the entire function?
    Striker*
    -Have any question, concerns or problems?
    Message me on forums, click on the link if you need help: http://era-go.com/forum/member.php?410-Striker
    Need help on iEra P.M my nick name is Striker*
    -Need further help? My email is:[email protected]
    ENjOY PLAYING IERA!!!!!
    -Gani Artist

  8. #18
    El Bacon Hombre Police Commissioner
    Join Date
    Jun 2013
    Location
    United States
    Posts
    247
    Quote Originally Posted by Striker View Post
    What do you mean by they aren't the same, isn't this. go through the entire function?
    Serverside and clientside aren't even operated on the same things.
    Clientside is compiled then sent off to be executed on the client whilst serverside is compiled then sent off to be executed by the server.

    Therefore, this. variables will go through the whole script, but only on the size it's instanced on. So, a this.timer = 5; declaration on serverside will not set this.timer = 5; on clientside and vice versa.

  9. #19
    Quote Originally Posted by John View Post
    PHP Code:
    function onCreated() {
      
      
    0;
      
      if (
    5) break;

      echo(
    i);

      
    += 1// or i++; whatever

      
    if (5) break;

      echo(
    i);

      
    +=1;

      if (
    5) break;

      echo(
    i);

      
    += 1;

      if (
    5) break;

      echo(
    i);

      
    += 1;

      if (
    5) break;

      echo(
    i);

      
    += 1;
      
    // etc

    Are you using break right? It looks like it wouldn't do anything.

  10. #20
    Street Boss John's Avatar
    Join Date
    Jun 2013
    Location
    Lebanon
    Posts
    825
    Quote Originally Posted by bobo View Post

    Are you using break right? It looks like it wouldn't do anything.
    Replace break; with return, this was an example, that's why it's important to use loops instead of nub coding lol.
    -Johnaudi

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •