Jump to content

how to use the "while true" structure?


Recommended Posts

 

should answer your (moronic) question

There are no "moronic" questions Sig. Please be a little nicer to newbs... even yair lol. tounge.gif

 

And yeah while true loops indefinitely unless it's stopped by a break or a jump to another label.

 

While <condition> will loop indefinitely until the condition is false.

You asked about true confused.gif

 

 

$var = 10while $var > 11  inc($var)end

 

 

should answer your (moronic) question

read SB help> Coding > Loops first before posting any other question

Dont be so hard with the guy, high level contructions are not easy for newbs.

what does the inc $var mean in this line?

i mean, is it like $var -= 1?

so the while structure, is basically like "for" in C++? just the other way arround i think, instead of "for $var == 0..."

but you used:

 

$var = 10while $var > 11

 

 

so, the var isnt > 10

 

what does the inc $var mean in this line?

i mean, is it like $var -= 1?

so the while structure, is basically like "for" in C++? just the other way arround i think, instead of "for $var == 0..."

but you used:

 

$var = 10while $var > 11

 

 

so, the var isnt > 10

That loop will never run as the var is 10 and the condition is "greater than 11" but anyways.

 

It's like so:

 

 

$var = 10 // set the value of the global variable "$var" to 10while $var > 11 // while the value of the global variable "$var" is greater than 11

 

 

The loops are the same as the C++ loops, for/while etc.

Inc($Var) = $Var+=1 (equals [var]++ in C-languages)

Dec($Var) = $Var-=1 ( " [var]-- in C-lnguages)

 

I'm sorry yair, I was in a bad moode yesterday! ( I know thats not realy an apology for being sarcastic[in huge circuemstances tounge.gif] and sometimes realy rude)

 

Don't take it to heart icon14.gif

 

for further features check out

SB Help> Coding> Loops
(read the whole page) and
SB Help> Coding > Additional Commands

 

cheers

 

@Adler: Your MSN brocken or what tounge.gif

 

Edit:

 

Nope, the For loop of Sannybuilder is not equal to the C++/#

 

for (int i = 0; i<[var]; [iteration]{}

 

 

there is a difference consirdering the condition (SilentPL told me tounge.gif)

 

Edited by The_Siggi

but..while true can be used as a custom timer(not 32@, 33@)

$var = 10

 

while $var >= 1

$var -= 1

end

actor.destroyinstantly...

 

I'm sorry yair, I was in a bad moode yesterday! ( I know thats not realy an apology for being sarcastic[in huge circuemstances tounge.gif] and sometimes realy rude)

hmm...im getting used to it tounge.gif

Its pretty easy to "convert" a For statment in a While or Repeat. Wich means Incondtional iteration to a Conditional one.

 

But may not be possible (in most cases) to do the opposite, convert a While or Repeat to a For.

 

Thats what you need to know about the diferences between them.

 

Also a While may Not execute its body, but a Repeat will do it atleast once.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • 0 User Currently Viewing
    0 members, 0 Anonymous, 0 Guests

×
×
  • Create New...

Important Information

By using GTAForums.com, you agree to our Terms of Use and Privacy Policy.