![]() |
|
[Tutorial] Basic GSC Coding: Functions - Printable Version +- ItsMods (https://www.itsmods.com) +-- Forum: Call of Duty Franchise (https://www.itsmods.com/Forum-Call-of-Duty-Franchise.html) +--- Forum: Call of Duty: Modern Warfare 2 (https://www.itsmods.com/Forum-Call-of-Duty-Modern-Warfare-2.html) +---- Forum: Tutorials (https://www.itsmods.com/Forum-Tutorials--44.html) +----- Forum: Yamato's Tutorial Zone (https://www.itsmods.com/Forum-Yamato-s-Tutorial-Zone.html) +----- Thread: [Tutorial] Basic GSC Coding: Functions (/Thread-Tutorial-Basic-GSC-Coding-Functions.html) Pages:
1
2
|
Basic GSC Coding: Functions - Yamato - 03-01-2012 Hello This is my second basic tutorial about GSC, this time is about Functions, I will explain how are they and how to call them, gsc codes are mostly all inside functions, by calling new functions you do different things in game, a function structure is like this. Code: Function1( )
{
CODES HERE
}The thing I called "Function1" is the name I put to the function, the "( )" is added because without it, is not a function (it is needed). Then there is a opening bracket ( { ), after it is where you are going to place your code and when you have ended writing it, you must close the function with a closing bracket ( } ). An example of function: Code: SayTheWords()
{
self iPrintLnBold( "You are reading" );
wait ( 1 );
self iPrintLnBold( "Functions tutorial" );
}Something you cant make on a function is to put 2 functions in 1, example: Code: FunctionA()
{
FunctionB()
{
SOMETHING
}
}By adding a code to a file, it wont be enough to make it work, so, youll have to "thread"/call it. There are many ways, Ill say a few of them, the most used one is this one: Code: self thread YOUR FUNCTION NAME;There are also this shortened versions for 2 things I am not explaining here: Code: self YOUR FUNCTION NAME;
YOUR FUNCTION NAME;To call this function: Code: SayTheWords()
{
self iPrintLnBold( "You are reading" );
wait ( 1 );
self iPrintLnBold( "Functions tutorial" );
}You would need to call it like this: Code: self thread SayTheWords();A function name can also have inside the "( )" variables which have some use inside the function, for example: Code: SayTheWords2( thing1, tutorial )
{
self iPrintLnBold( thing1 );
wait ( 1 );
self iPrintLnBold( tutorial );
}It will say first what I put in "thing1" and then what I put in "tutorial", for example, I could call it like this: Code: self thread SayTheWords2( "Hello Itsmods", "You are reading Functions Tutorial" );I hope you have liked it, any questions: just ask. Thanks for reading, @Yamato RE: Basic GSC Coding: Functions - Pozzuh - 03-01-2012 You know there is a difference between Code: self doShit();Code: self thread doShit();For example if the function doShit() would be: Code: doShit()
{
wait 5;
iPrintLnBold("Waited 5 sec.");
}
Main()
{
doShit();
iPrintLnBold("This will happen AFTER it waited 5 sec, because it went in the doShit function");
}
Main2()
{
thread doShit();
iPrintLnBold("This will happen instantaneously. And after 5 sec it will still say 'waited 5 sec'. ");
}RE: Basic GSC Coding: Functions - Yamato - 03-01-2012 (03-01-2012, 17:49)Pozzuh Wrote: My explanations are I edited the main post with the missing words,
RE: Basic GSC Coding: Functions - Pozzuh - 03-01-2012 (03-01-2012, 17:55)Yamato Wrote: RE: Basic GSC Coding: Functions - zxz0O0 - 03-01-2012 Still wrong. It's not a "short" version, it's just that one function is threaded. The CPU will switch really fast between these threads so it looks like they are running parallel. If you don't use threads function1 will call function2 and wait for function2 to finish so function1 can continue. Apart from that nice tutorial. RE: Basic GSC Coding: Functions - Bloodfocus - 03-02-2012 necesito saber mas para hacer mi propio code ? (perdon si te molesto con preguntas , es que soy muy n00b en GSC XD) RE: Basic GSC Coding: Functions - aosma8 - 03-02-2012 (03-02-2012, 04:57)VerifyerModderz Wrote: necesito saber mas para hacer mi propio code ? (perdon si te molesto con preguntas , es que soy muy n00b en GSC XD) English forum only lol. RE: Basic GSC Coding: Functions - Pozzuh - 03-02-2012 (03-02-2012, 04:57)VerifyerModderz Wrote: necesito saber mas para hacer mi propio code ? (perdon si te molesto con preguntas , es que soy muy n00b en GSC XD) Nano saber mass Paper hacker my proper code? (Pardon is child molester. Console pregnancy, is cool oi, I'm n00b and gsc XD) RE: Basic GSC Coding: Functions - Yamato - 03-02-2012 (03-02-2012, 09:45)Pozzuh Wrote:(03-02-2012, 04:57)VerifyerModderz Wrote: necesito saber mas para hacer mi propio code ? (perdon si te molesto con preguntas , es que soy muy n00b en GSC XD) Fail.
RE: Basic GSC Coding: Functions - JariZ - 03-02-2012 Consoles are indeed pregnant |