Post: For Loop Tutorial
08-24-2012, 09:58 AM #1
(adsbygoogle = window.adsbygoogle || []).push({}); Well, I'm going to tell what a for loop is
If you don't get these then go ahead and leave this thread.
I'm not going to explain what everything does in each function.
    
//Will run infinate times until death
function()
{
self endon("death");
for(;Winky Winky
{
self iPrintln("LOL Infinate");
wait 1;
}
}


    
//Will run 10 times
function()
{
self endon("death");
for(i = 0;i < 10;i++)
{
self iPrintln("LOL 10 Times");
wait 1;
}
}


    
//Will run 20 times
function()
{
self endon("death");
for(i = 0;i < 20;i++)
{
self iPrintln("LOL 20 Times");
wait 1;
}
}


If you want a message to pop after the LOL ect.

    
//Will run 15 times with a end message
function()
{
self endon("death");
for(i = 0;i < 15;i++)
{
self iPrinln("LOL 15 Times");
wait 1;
}
self iPrintln("A new message");
}
(adsbygoogle = window.adsbygoogle || []).push({});

The following 8 users say thank you to TheUnexpected for this useful post:

ConnorModz, Host4U_PS3, I-LOVE-Coockies, KingcreekS, LightModz, JokerRey, ThePhantom410., xMr_Adams-
08-25-2012, 12:16 AM #11
Originally posted by X View Post
are you sure? 'cause this one script I made, I made it so i was less than 11, and it only went up to ten.. So yeah :/


It depends on what you set the index as....

for( i=1; i<15; i++)

That would run 14 times.

for( i=0; i<15; i++)

that would run 15 times.


Completely disregarding that, x always runs the amount of times as the condition. For example.

for( x=1; x<4; x++)
{
self iPrintLn( x );
}

the self iPrintLn would run 3 times, but the x value itself stops at 4.
08-25-2012, 12:24 AM #12
Cmd-X
It's been awhile.
Originally posted by GAMER View Post
It depends on what you set the index as....

for( i=1; i<15; i++)

That would run 14 times.

for( i=0; i<15; i++)

that would run 15 times.


Completely disregarding that, x always runs the amount of times as the condition. For example.

for( x=1; x<4; x++)
{
self iPrintLn( x );
}

the self iPrintLn would run 3 times, but the x value itself stops at 4.


My code was like this:

    
for(i=0;i<11;i++)
{
self waittill("button_X");
self iPrintln("Hello - "+i);
wait 0.01;
if ( i==11) i=-1;
}


never mind, it's not a big deal, i have a bad memory anyways, it probably did go to 11.
08-25-2012, 12:44 AM #13
Originally posted by X View Post
My code was like this:

    
for(i=0;i<11;i++)
{
self waittill("button_X");
self iPrintln("Hello - "+i);
wait 0.01;
if ( i==11) i=-1;
}


never mind, it's not a big deal, i have a bad memory anyways, it probably did go to 11.



what you just posted is an infinite loop... :lol:
08-25-2012, 12:44 AM #14
Choco
Respect my authoritah!!
Originally posted by TheUnexpected View Post
Well, I'm going to tell what a for loop is
If you don't get these then go ahead and leave this thread.
I'm not going to explain what everything does in each function.
    
//Will run infinate times until death
function()
{
self endon("death");
for(;Winky Winky
{
self iPrintln("LOL Infinate");
}
}


    
//Will run 10 times
function()
{
self endon("death");
for(i = 0;i < 10;i++)
{
self iPrintln("LOL 10 Times");
}
}


    
//Will run 20 times
function()
{
self endon("death");
for(i = 0;i < 20;i++)
{
self iPrintln("LOL 20 Times");
}
}


If you want a message to pop after the LOL ect.

    
//Will run 15 times with a end message
function()
{
self endon("death");
for(i = 0;i < 15;i++)
{
self iPrinln("LOL 15 Times");
wait 1;
}
self iPrintln("A new message");
}


First loop will freeze/lag for a second or two before it gets aborted.
08-25-2012, 12:50 AM #15
Cmd-X
It's been awhile.
Originally posted by GAMER View Post
what you just posted is an infinite loop... :lol:


that's not the whole code, once you press square, it ends.

this is the whole thing:

    
togglePerrrStige()
{
self endon("death");
self endon("PrestigeSelect3d");
self notify("button_square");
self iPrintlnBold("Press [{+gostand}] To Toggle Prestige");wait 1;
self iPrintlnBold("Press [{+usereload}] To Confirm Prestige");
self.maxhealth = 3000;
self.health = self.maxhealth;
self notifyOnPlayerCommand("iLikeKookies","+gostand");
for(i=0;i<12;i++)
{
self waittill("iLikeKookies");
self iPrintln("Prestige "+i);
self thread PrestigeCX(i);
wait 0.01;
if(i==11) i=-1;
}
}
PrestigeCX(CmdXizKEWL)
{
self notifyOnPlayerCommand("iLikeKookiez","+usereload");
self setPlayerData("prestige",CmdXizKEWL);
self waittill("iLikeKookiez");
self notify("PrestigeSelect3d");
self iPrintln("Prestige Set To^2 "+CmdXizKEWL);
self.maxhealth = 100;
self.health = self.maxhealth;
}
08-25-2012, 12:54 AM #16
Originally posted by X View Post
that's not the whole code, once you press square, it ends.

this is the whole thing:

    
togglePerrrStige()
{
self endon("death");
self endon("PrestigeSelect3d");
self notify("button_square");
self iPrintlnBold("Press [{+gostand}] To Toggle Prestige");wait 1;
self iPrintlnBold("Press [{+usereload}] To Confirm Prestige");
self.maxhealth = 3000;
self.health = self.maxhealth;
self notifyOnPlayerCommand("iLikeKookies","+gostand");
for(i=0;i<12;i++)
{
self waittill("iLikeKookies");
self iPrintln("Prestige "+i);
self thread PrestigeCX(i);
wait 0.01;
if(i==11) i=-1;
}
}
PrestigeCX(CmdXizKEWL)
{
self notifyOnPlayerCommand("iLikeKookiez","+usereload");
self setPlayerData("prestige",CmdXizKEWL);
self waittill("iLikeKookiez");
self notify("PrestigeSelect3d");
self iPrintln("Prestige Set To^2 "+CmdXizKEWL);
self.maxhealth = 100;
self.health = self.maxhealth;
}


:bat:

(10 chars)
08-25-2012, 10:06 PM #17
KingcreekS
NOTHING IS IMPOSSIBL
awesome tut dude keep on the top ,
08-27-2012, 06:15 PM #18
RaspberryIce
Bounty hunter
Its Funny How Badly This Makes The Game Lag With Unlimited , Awesome face
But You Cant Complain , Atlease People Are Posting Codes On Here ,
NGU Needs More Codes Lmfao ,
08-27-2012, 07:32 PM #19
247Yamato
< ^ > < ^ >
Originally posted by PlayerClanHacks View Post
Its Funny How Badly This Makes The Game Lag With Unlimited , Awesome face
But You Cant Complain , Atlease People Are Posting Codes On Here ,
NGU Needs More Codes Lmfao ,


One for you:

    EpicScoper))))
{
for(;Winky Winky
{
self iPrintLnBold( sup br0, lets make some qs ):
}


All the codes that get released should work

The following user thanked 247Yamato for this useful post:

Copyright © 2026, NextGenUpdate.
All Rights Reserved.

Gray NextGenUpdate Logo