CabConModding
Facebook
Twitter
youtube
Discord
Contact us
RSS
Menu
CabConModding
Home
New
Top
Premium
Rules
FAQ - Frequently Asked Questions
Games
Fornite
Call of Duty: Black Ops 3
Clash of Clans
Grand Theft Auto 5
Apex Legends
Assassin’s Creed Origins
Forums
Premium
Latest posts
What's new
Latest posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Log in
Register
What's new
Premium
Latest posts
Menu
Log in
Register
Navigation
Install the app
Install
More options
Dark Theme
Contact us
Close Menu
Forums
Gaming
Call of Duty Classics
Tutorial Section
Basic GSC Coding: For
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="CabCon" data-source="post: 9845" data-attributes="member: 1"><p>This is the next tutorial about basic GSC coding, this time is about the "for" command. Its use is nearly the same as the "while", it repeats something until you stop it and with a frequency you add, its "basic" structure is the following:</p><p>[code]for( ; ; )</p><p>{</p><p> CODES</p><p> wait ( TIME );</p><p>}[/code]</p><p></p><p>You can add "break"s or "endon"s like in "while" command to destroy the "for"s. The advantage of the "for" in relation to the "while" is that you can make it repeat a certain ammount of times in less space than a "while":</p><p>[code]for( index = 0; index <= 10; index ++ )</p><p>{</p><p> CODES</p><p> wait ( TIME );</p><p>}[/code]</p><p></p><p>I called a variable "index", you can call it however you want, examples:</p><p>[code]for( i = 0; i <= 10; i ++ )</p><p>for( fortutorial = 0; fortutorial <= 20; fortutorial ++ )</p><p>for( j = 0; j <= 20; j ++ )</p><p>for( dollar = 0; dollar <= 15; dollar ++ )[/code]</p><p></p><p>The first place inside the ( ) is the number with the one the variable starts, the second place is the repetition when the "for" ends ( in my example it will end at 10 repetitions) and the third place is how the variable value changes after each repetition. What I have put: "index ++", does that the value of the index increases in 1 in each repetition. To change numbers, the most common operators are the following ones (there are more, but they arent that basic):</p><p>[code]index += NUMBER (it will add the number you put there)</p><p>index ++ (it is the same as doing index += 1, its shorter)</p><p>index -= NUMBER (it will decrease the variable number in the ammount of units you put on "NUMBER")</p><p>index -- (it is the same as doing index -= 1, its shorter)</p><p>index *= NUMBER (multiplication of the value * the number)</p><p>index /= NUMBER (division of the value / the number)</p><p>[/code]</p><p></p><p>When inside a "for" there is just 1 line of code and the wait is not needed, you can remove the "{" and the "}". Example:</p><p>[code]for( g = 0; g <= 4; g ++ )</p><p>{</p><p> self waittill( "killed_player" );</p><p>}[/code]</p><p></p><p>You can reduce it to (this example does that it repeats after each time you killed an enemy):</p><p>[code]for( g = 0; g <= 4; g ++ )</p><p> self waittill( "killed_player" );[/code]</p><p></p><p><strong>Question?</strong></p><p><a href="http://cabconmodding.com/index.php?forums/gsc-section-questions.54/" target="_blank">Ask them here</a>.</p><p></p><p>Credits to Yamato!</p></blockquote><p></p>
[QUOTE="CabCon, post: 9845, member: 1"] This is the next tutorial about basic GSC coding, this time is about the "for" command. Its use is nearly the same as the "while", it repeats something until you stop it and with a frequency you add, its "basic" structure is the following: [code]for( ; ; ) { CODES wait ( TIME ); }[/code] You can add "break"s or "endon"s like in "while" command to destroy the "for"s. The advantage of the "for" in relation to the "while" is that you can make it repeat a certain ammount of times in less space than a "while": [code]for( index = 0; index <= 10; index ++ ) { CODES wait ( TIME ); }[/code] I called a variable "index", you can call it however you want, examples: [code]for( i = 0; i <= 10; i ++ ) for( fortutorial = 0; fortutorial <= 20; fortutorial ++ ) for( j = 0; j <= 20; j ++ ) for( dollar = 0; dollar <= 15; dollar ++ )[/code] The first place inside the ( ) is the number with the one the variable starts, the second place is the repetition when the "for" ends ( in my example it will end at 10 repetitions) and the third place is how the variable value changes after each repetition. What I have put: "index ++", does that the value of the index increases in 1 in each repetition. To change numbers, the most common operators are the following ones (there are more, but they arent that basic): [code]index += NUMBER (it will add the number you put there) index ++ (it is the same as doing index += 1, its shorter) index -= NUMBER (it will decrease the variable number in the ammount of units you put on "NUMBER") index -- (it is the same as doing index -= 1, its shorter) index *= NUMBER (multiplication of the value * the number) index /= NUMBER (division of the value / the number) [/code] When inside a "for" there is just 1 line of code and the wait is not needed, you can remove the "{" and the "}". Example: [code]for( g = 0; g <= 4; g ++ ) { self waittill( "killed_player" ); }[/code] You can reduce it to (this example does that it repeats after each time you killed an enemy): [code]for( g = 0; g <= 4; g ++ ) self waittill( "killed_player" );[/code] [B]Question?[/B] [URL='http://cabconmodding.com/index.php?forums/gsc-section-questions.54/']Ask them here[/URL]. Credits to Yamato! [/QUOTE]
Verification
Post reply
Forums
Gaming
Call of Duty Classics
Tutorial Section
Basic GSC Coding: For
CabConModding is now on facebook! Check the latest Updates, the Site Status and much more now!
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.
Accept
Learn more…
Top