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
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
Call of Duty: Black Ops 2 Scripts Questions
Call of Duty: Black Ops 2 Answered Questions
GSC
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="vampytwist" data-source="post: 26737" data-attributes="member: 31216"><p>Also this may help you out.</p><p></p><p>Credits to Shark for writing this up:</p><p></p><p><strong>Contents</strong></p><p><strong>--------------------------</strong></p><p><strong>Setting Up</strong></p><p><strong>Understanding The Syntax</strong></p><p><strong>Understanding Variables</strong></p><p><strong>Using Includes</strong></p><p><strong>Basic Scripting</strong></p><p><strong>Threading</strong></p><p><strong>Running The GSC</strong></p><p><strong>GSC Functions</strong></p><p><strong>Coding A Function Neatly</strong></p><p><strong>FAQ</strong></p><p><strong></strong></p><p><strong><strong>Setting Up</strong></strong></p><p><strong><strong></strong></strong></p><p><strong>[spoiler]</strong></p><p><strong>In order to code GSC you do not need any fancy or pricy programs to do so, all you need is a simple text editor.</strong></p><p><strong>If you want you could use the default notepad application that comes with windows but if you prefer something a bit more advanced that has syntax highlighting and some other groovy features then I suggest using some of the programs I have listed below.</strong></p><p><strong></strong></p><p><strong><strong>Notepad++</strong></strong></p><p><strong><strong>Sublime Text</strong></strong></p><p><strong><strong>UltraEdit</strong></strong></p><p><strong><strong>GSC Studio By iMCSx</strong></strong></p><p><strong>I'm sure if you were to do a quick google search you could find more but these are probably the best ones!</strong></p><p><strong></strong></p><p><strong>Once you have your desired text editor create a new document and call it "_clientids.txt" for now, the reason we are calling it this because this is an existing file within the game, we are going to overwrite it with our own edited one later.</strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Understanding The Syntax</strong></strong></p><p><strong>[spoiler] </strong></p><p><strong></strong></p><p><strong>If you are new to coding getting your head around the syntax can take quiet a bit of time to get the hang off.</strong></p><p><strong>If you are unsure what I mean by "The Syntax" then feel free to google it and come back when you are ready <img src="http://i.imgur.com/yIlcNgV.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></strong></p><p><strong></strong></p><p><strong>The Syntax in GSC is similar to most general programming languages such as C++, C#, Ruby and many more.</strong></p><p><strong></strong></p><p><strong>The 2 Curly Brackets Are Used To Define where the start and end of your functions/statements are.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>Curly Brackets: { }</strong></p><p><strong>Example</strong></p><p><strong>funcName()</strong></p><p><strong>{ //Starting My Function</strong></p><p><strong> </strong></p><p><strong>} //Ending It</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>The Semi-Colon is used to define where a line or statement will end it is also used as a separator in some cases. </strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>Semi-Colon: ;</strong></p><p><strong>Example</strong></p><p><strong>funcName(); //By Putting The Semi-Colon I Am Ending My Line/Statement So My Code Knows To Go To The Next Line</strong></p><p><strong>Example 2</strong></p><p><strong>for (i = 0; i < 10; i++)//In This Example You Can See Im Using The Semi-Colon To Seperate The Variables</strong></p><p><strong>{ }</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>The Brackets are mainly used to indicate an argument, to tell the compiler what data type the function needs to look for first in order to start.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>Brackets: ( )</strong></p><p><strong>Example</strong></p><p><strong>number = 1;</strong></p><p><strong>funcName(number)//Initialising A Function With The Argument being number</strong></p><p><strong>//An argument is only to be included if the function supports them if not I would just put brackets with nothing inside</strong></p><p><strong>funcName();</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>The Square Brackets Are Really Only Used To Declare & Access Arrays</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>Square Brackets: [ ]</strong></p><p><strong>Example</strong></p><p><strong>studentAge["Justin"] = 15;</strong></p><p><strong>studentAge["Brandon"] = 16;</strong></p><p><strong></strong></p><p><strong>number = studentAge["Justin"] //Number would know be equal to 15</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>Quotation Marks Are Used For Declaring A String</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>Quotation Marks: " "</strong></p><p><strong>Example</strong></p><p><strong>myName = "Justin"//myName is now equal to Justin</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Understanding Variables</strong></strong></p><p><strong>[spoiler]</strong></p><p><strong></strong></p><p><strong>A Variable is used as a storage point, they are used within almost every programming language and are extremely useful for storing any type of data.</strong></p><p><strong></strong></p><p><strong>Before declaring a variable you should first know about all the different data types, ill list them below.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>String</strong></p><p><strong>Boolean</strong></p><p><strong>Float</strong></p><p><strong>Integer[/code]</strong></p><p><strong></strong></p><p><strong>There is many more but this is all you will need to know for GSC</strong></p><p><strong></strong></p><p><strong>Now To declare a variable its actually quiet simple, you don't need to say what type of variable it is you are declaring you just need to put the data in, ill put some examples below.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>self.stringVariable = "MyString";</strong></p><p><strong>self.integerVariable = 1;</strong></p><p><strong>self.floatVariable = 1;</strong></p><p><strong>self.booleanVariable = true;</strong></p><p><strong></strong></p><p><strong>[/code]</strong></p><p><strong>The names of your variables can be anything you desire, by doing self.variableName I am defining a variable for my own player in GSC, I will talk about this later in <strong>Basic Scripting</strong>.[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Using Includes</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>I'm sure everyone has seen it when at the top of a GSC code you see something that looks like this</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>#include maps/mp/gametypes/_file</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>Think of an include as a way of copying and pasting, what the above code would be doing is copying and pasting all the contents from another GSC file into our GSC file.</strong></p><p><strong>But why would we want to do this? well the answer to that is quiet simple, so we can use the functions that are in that GSC file in our own GSC file if you do not want to include the whole GSC file and only wanted to call 1 function from that file then you could do the below method aswell</strong></p><p><strong></strong></p><p><strong>[code]</strong></p><p><strong>self maps\mp\_gscfile::funcName()</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>This will allow us to call a function from another namespace without including it, the double colon indicates we are calling the function the desired namespace</strong></p><p><strong>[/code]</strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Basic Scripting</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>Now I Will Talk About The Basics of GSC Scripting!</strong></p><p><strong></strong></p><p><strong>If you have ever seen GSC Coding before I'm sure you are wondering what it means by self and player and all that other stuff that you see before functions.</strong></p><p><strong>Well to start off self means the entity/player that is calling the current script, example lets say my player just spawned and I run the code below.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>self freezeControls(true);</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>Now from what I have told you we know that self is my player because my player is calling this code, so therefore my players controls will be frozen.</strong></p><p><strong></strong></p><p><strong>Now for a more complex example.</strong></p><p><strong>Lets say we have a function with the argument player.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>freezePlayer(player)</strong></p><p><strong>{</strong></p><p><strong> player freezeControls(true);</strong></p><p><strong>}</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>Now I'm sure you are wondering how we are supposed to call this if we don't know what to put in the player argument, well ill explain.</strong></p><p><strong>There is an array that stores all the players in it, this is what we will use for our argument.</strong></p><p><strong>So to call it we could do both ways listed below.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>freezePlayer(level.players[0]); //Freeze Client 0</strong></p><p><strong></strong></p><p><strong>freezePlayer(self); //Freeze Player Running The Code</strong></p><p><strong>[/code]</strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Threading</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>Now we know the basics lets move onto something a tiny bit more complex, threading.</strong></p><p><strong>Threading is extremely useful within GSC, it is mainly used when doing loops, if we were to create a loop on the main thread we would probably freeze the game, but if we were to make a new thread what would happen is that the main thread would keep running and a new thread would run next to it therefore preventing the game from freezing.</strong></p><p><strong></strong></p><p><strong>Before creating a new thread that uses a loop there is one thing you should know which is that a loop must have a small wait time, if not your game will lag out and freeze ill provide an example shortly of how to add a wait. </strong></p><p><strong></strong></p><p><strong>to create a new thread its fairly straight forward all you need to do is put thread infront of where your calling your function.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>myLoop()//Defining The Function With The Loop</strong></p><p><strong>{</strong></p><p><strong> self endon("disconnect");//Ends the thread if player disconnects or dies.</strong></p><p><strong> self endon("death");</strong></p><p><strong> self.number = 1;</strong></p><p><strong> for (;;)</strong></p><p><strong> {</strong></p><p><strong> self.number++; //Increase the number by 1 constantly</strong></p><p><strong> wait 0.05; //stop it from lagging and freezing.</strong></p><p><strong> }</strong></p><p><strong>}</strong></p><p><strong></strong></p><p><strong>//Calling It On A New Thread</strong></p><p><strong>self thread myLoop(); //This will make a new thread and run myLoop</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong></strong></p><p><strong><strong>Running The GSC</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong>In Order to load and run the GSC you have made you are going to need the GSC Compiler in order to convert your .txt file into a .gsc file you are also going to need a GSC Injector which is used to load the GSC onto your console/pc</strong></p><p><strong></strong></p><p><strong>You can find the compilers and loaders on the internet I am not going to provide links to them.</strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>GSC Functions</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>There is thousands of functions that can be used within GSC, but since there is to many to name I am just going to tell you about some of the useful ones and explain them.</strong></p><p><strong></strong></p><p><strong>[code]</strong></p><p><strong>//<Optional Arg></strong></p><p><strong>waittill(event, <return>) //Waits Until An Event Happens Before Executing The Code Below It</strong></p><p><strong>endon(event) //Ends a thread/function when an event happens</strong></p><p><strong>iPrintln(text) //Prints text to killfeed</strong></p><p><strong>iPrintlnBold(text) //Prints text to center of screen</strong></p><p><strong>[/code]</strong></p><p><strong></strong></p><p><strong>You can find the names of more functions by using google</strong></p><p><strong>or by exploring the gsc files from the game</strong></p><p><strong></strong></p><p><strong>You can also find a large list of functions here: <a href="http://www.zeroy.com/script/" target="_blank">ZeRoY's Call Of Duty Script Reference</a></strong></p><p><strong></strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>Coding A Function Neatly</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>I'm not sure if everyone is the same as me but I cant stand seeing ugly codes, this does not mean your code is bad it just makes it harder to understand for others and sometimes for yourself if you want to go back and review it to improve it or check something in it.</strong></p><p><strong></strong></p><p><strong>Below is an example of what I would call an "ugly" code. (I just used a function I found on X website and made it ugly <img src="/styles/default/xenforo/smilies.emoji/people/stuck_out_tongue_closed_eyes.emoji.svg" class="smilie" loading="lazy" alt=":tongueclosed:" title="Tongue Closed Eyes :tongueclosed:" data-shortname=":tongueclosed:" />)</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>crateGun()</strong></p><p><strong>{</strong></p><p><strong>self endon("disconnect")</strong></p><p><strong>self endon("death")</strong></p><p><strong>self iPrintln("press shoot button to shoot care packages");</strong></p><p><strong>for(;;)</strong></p><p><strong>{</strong></p><p><strong>self waittill ("weapon_fired");</strong></p><p><strong>self thread maps\mp\killstreaks\_supplydrop::dropcrate(self traceBullet(), self traceBullet()[2], "supplydrop_mp", self, self.team, self.killcament, undefined, undefined, undefined);</strong></p><p><strong>wait 1;</strong></p><p><strong>}</strong></p><p><strong>}[/code]</strong></p><p><strong></strong></p><p><strong>Now looking at this code its very hard to read and everything is really close together now below I'm going to show you the neat version of this function</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>crateGun()</strong></p><p><strong>{</strong></p><p><strong> self endon("disconnect")</strong></p><p><strong> self endon("death")</strong></p><p><strong></strong></p><p><strong> self iPrintln("Care Package Gun!, Shoot To Spawn Care Packages");</strong></p><p><strong> for(;;)</strong></p><p><strong> {</strong></p><p><strong> self waittill ("weapon_fired");</strong></p><p><strong> self thread maps\mp\killstreaks\_supplydrop::dropcrate(self traceBullet(), self traceBullet()[2], "supplydrop_mp", self, self.team, self.killcament, undefined, undefined, undefined);</strong></p><p><strong> wait 1;</strong></p><p><strong> }</strong></p><p><strong>}[/code]</strong></p><p><strong></strong></p><p><strong>You can see I have added indents and changed the iPrintln to something more formal.</strong></p><p><strong>If you are unsure how to do your indentations correctly then I will briefly explain.</strong></p><p><strong></strong></p><p><strong>Indentations are not important and will not affect the way your code functions but like I said before they make your code much more readable and formal. If you are using a text editor like one of the ones I suggested at the start of this tutorial then getting your indentations correct is easy on every keyboard we have a magical button called the "tab button" what this will do is move your writing pointer across a number of spaces depending on where you have pressed tab from.</strong></p><p><strong>To indent a function correctly is simple all you have to do is indent your code inside each new code block, example below and further explaination below.</strong></p><p><strong><img src="http://puu.sh/bA1Mc/6c2d59affc.png" alt="" class="fr-fic fr-dii fr-draggable " style="" /></strong></p><p><strong>Basically for each code block you define you have to press tab for each code block you are writing in, if you are writing in the main code block you only indent once if you are writing inside a code block thats in the main code block then you indent twice etc.</strong></p><p><strong></strong></p><p><strong>As for making your code more understandable try to name things to what they are so they make more sense, example below.</strong></p><p><strong></strong></p><p><strong>[Code]</strong></p><p><strong>//Lets Compare</strong></p><p><strong>self.swagjumpmodeon = true;</strong></p><p><strong>//To</strong></p><p><strong>self.superJump = true;</strong></p><p><strong></strong></p><p><strong>//Which one do you understand more? The Bottom One? yea though so...</strong></p><p><strong>//Same goes with function names and anything else that requires naming[/code]</strong></p><p><strong></strong></p><p><strong>So just remember to code your functions correctly especially if you are releasing them!</strong></p><p><strong>[/spoiler]</strong></p><p><strong></strong></p><p><strong><strong>FAQ</strong></strong></p><p><strong>[Spoiler]</strong></p><p><strong></strong></p><p><strong>Q: My Game Freezes On Loading Screen</strong></p><p><strong>A: This Means You Either Have A Non-Existant Function or A Syntax Error!</strong></p><p><strong></strong></p><p><strong>Q: Connection Interrupted then Freeze when calling a function or spawning in</strong></p><p><strong>A: This Means You Have A Loop With No Waits</strong></p><p><strong></strong></p><p><strong>[/spoiler]</strong></p></blockquote><p></p>
[QUOTE="vampytwist, post: 26737, member: 31216"] Also this may help you out. Credits to Shark for writing this up: [B]Contents -------------------------- Setting Up Understanding The Syntax Understanding Variables Using Includes Basic Scripting Threading Running The GSC GSC Functions Coding A Function Neatly FAQ [B]Setting Up [/B] [spoiler] In order to code GSC you do not need any fancy or pricy programs to do so, all you need is a simple text editor. If you want you could use the default notepad application that comes with windows but if you prefer something a bit more advanced that has syntax highlighting and some other groovy features then I suggest using some of the programs I have listed below. [B]Notepad++ Sublime Text UltraEdit GSC Studio By iMCSx[/B] I'm sure if you were to do a quick google search you could find more but these are probably the best ones! Once you have your desired text editor create a new document and call it "_clientids.txt" for now, the reason we are calling it this because this is an existing file within the game, we are going to overwrite it with our own edited one later. [/spoiler] [B]Understanding The Syntax[/B] [spoiler] If you are new to coding getting your head around the syntax can take quiet a bit of time to get the hang off. If you are unsure what I mean by "The Syntax" then feel free to google it and come back when you are ready [IMG]http://i.imgur.com/yIlcNgV.png[/IMG] The Syntax in GSC is similar to most general programming languages such as C++, C#, Ruby and many more. The 2 Curly Brackets Are Used To Define where the start and end of your functions/statements are. [Code] Curly Brackets: { } Example funcName() { //Starting My Function } //Ending It [/code] The Semi-Colon is used to define where a line or statement will end it is also used as a separator in some cases. [Code] Semi-Colon: ; Example funcName(); //By Putting The Semi-Colon I Am Ending My Line/Statement So My Code Knows To Go To The Next Line Example 2 for (i = 0; i < 10; i++)//In This Example You Can See Im Using The Semi-Colon To Seperate The Variables { } [/code] The Brackets are mainly used to indicate an argument, to tell the compiler what data type the function needs to look for first in order to start. [Code] Brackets: ( ) Example number = 1; funcName(number)//Initialising A Function With The Argument being number //An argument is only to be included if the function supports them if not I would just put brackets with nothing inside funcName(); [/code] The Square Brackets Are Really Only Used To Declare & Access Arrays [Code] Square Brackets: [ ] Example studentAge["Justin"] = 15; studentAge["Brandon"] = 16; number = studentAge["Justin"] //Number would know be equal to 15 [/code] Quotation Marks Are Used For Declaring A String [Code] Quotation Marks: " " Example myName = "Justin"//myName is now equal to Justin [/code] [/spoiler] [B]Understanding Variables[/B] [spoiler] A Variable is used as a storage point, they are used within almost every programming language and are extremely useful for storing any type of data. Before declaring a variable you should first know about all the different data types, ill list them below. [Code] String Boolean Float Integer[/code] There is many more but this is all you will need to know for GSC Now To declare a variable its actually quiet simple, you don't need to say what type of variable it is you are declaring you just need to put the data in, ill put some examples below. [Code] self.stringVariable = "MyString"; self.integerVariable = 1; self.floatVariable = 1; self.booleanVariable = true; [/code] The names of your variables can be anything you desire, by doing self.variableName I am defining a variable for my own player in GSC, I will talk about this later in [B]Basic Scripting[/B].[/spoiler] [B]Using Includes[/B] [Spoiler] I'm sure everyone has seen it when at the top of a GSC code you see something that looks like this [Code] #include maps/mp/gametypes/_file [/code] Think of an include as a way of copying and pasting, what the above code would be doing is copying and pasting all the contents from another GSC file into our GSC file. But why would we want to do this? well the answer to that is quiet simple, so we can use the functions that are in that GSC file in our own GSC file if you do not want to include the whole GSC file and only wanted to call 1 function from that file then you could do the below method aswell [code] self maps\mp\_gscfile::funcName() [/code] This will allow us to call a function from another namespace without including it, the double colon indicates we are calling the function the desired namespace [/code] [/spoiler] [B]Basic Scripting[/B] [Spoiler] Now I Will Talk About The Basics of GSC Scripting! If you have ever seen GSC Coding before I'm sure you are wondering what it means by self and player and all that other stuff that you see before functions. Well to start off self means the entity/player that is calling the current script, example lets say my player just spawned and I run the code below. [Code] self freezeControls(true); [/code] Now from what I have told you we know that self is my player because my player is calling this code, so therefore my players controls will be frozen. Now for a more complex example. Lets say we have a function with the argument player. [Code] freezePlayer(player) { player freezeControls(true); } [/code] Now I'm sure you are wondering how we are supposed to call this if we don't know what to put in the player argument, well ill explain. There is an array that stores all the players in it, this is what we will use for our argument. So to call it we could do both ways listed below. [Code] freezePlayer(level.players[0]); //Freeze Client 0 freezePlayer(self); //Freeze Player Running The Code [/code] [/spoiler] [B]Threading[/B] [Spoiler] Now we know the basics lets move onto something a tiny bit more complex, threading. Threading is extremely useful within GSC, it is mainly used when doing loops, if we were to create a loop on the main thread we would probably freeze the game, but if we were to make a new thread what would happen is that the main thread would keep running and a new thread would run next to it therefore preventing the game from freezing. Before creating a new thread that uses a loop there is one thing you should know which is that a loop must have a small wait time, if not your game will lag out and freeze ill provide an example shortly of how to add a wait. to create a new thread its fairly straight forward all you need to do is put thread infront of where your calling your function. [Code] myLoop()//Defining The Function With The Loop { self endon("disconnect");//Ends the thread if player disconnects or dies. self endon("death"); self.number = 1; for (;;) { self.number++; //Increase the number by 1 constantly wait 0.05; //stop it from lagging and freezing. } } //Calling It On A New Thread self thread myLoop(); //This will make a new thread and run myLoop [/code] [/spoiler] [B]Running The GSC[/B] [Spoiler] In Order to load and run the GSC you have made you are going to need the GSC Compiler in order to convert your .txt file into a .gsc file you are also going to need a GSC Injector which is used to load the GSC onto your console/pc You can find the compilers and loaders on the internet I am not going to provide links to them. [/spoiler] [B]GSC Functions[/B] [Spoiler] There is thousands of functions that can be used within GSC, but since there is to many to name I am just going to tell you about some of the useful ones and explain them. [code] //<Optional Arg> waittill(event, <return>) //Waits Until An Event Happens Before Executing The Code Below It endon(event) //Ends a thread/function when an event happens iPrintln(text) //Prints text to killfeed iPrintlnBold(text) //Prints text to center of screen [/code] You can find the names of more functions by using google or by exploring the gsc files from the game You can also find a large list of functions here: [URL='http://www.zeroy.com/script/']ZeRoY's Call Of Duty Script Reference[/URL] [/spoiler] [B]Coding A Function Neatly[/B] [Spoiler] I'm not sure if everyone is the same as me but I cant stand seeing ugly codes, this does not mean your code is bad it just makes it harder to understand for others and sometimes for yourself if you want to go back and review it to improve it or check something in it. Below is an example of what I would call an "ugly" code. (I just used a function I found on X website and made it ugly :tongueclosed:) [Code] crateGun() { self endon("disconnect") self endon("death") self iPrintln("press shoot button to shoot care packages"); for(;;) { self waittill ("weapon_fired"); self thread maps\mp\killstreaks\_supplydrop::dropcrate(self traceBullet(), self traceBullet()[2], "supplydrop_mp", self, self.team, self.killcament, undefined, undefined, undefined); wait 1; } }[/code] Now looking at this code its very hard to read and everything is really close together now below I'm going to show you the neat version of this function [Code] crateGun() { self endon("disconnect") self endon("death") self iPrintln("Care Package Gun!, Shoot To Spawn Care Packages"); for(;;) { self waittill ("weapon_fired"); self thread maps\mp\killstreaks\_supplydrop::dropcrate(self traceBullet(), self traceBullet()[2], "supplydrop_mp", self, self.team, self.killcament, undefined, undefined, undefined); wait 1; } }[/code] You can see I have added indents and changed the iPrintln to something more formal. If you are unsure how to do your indentations correctly then I will briefly explain. Indentations are not important and will not affect the way your code functions but like I said before they make your code much more readable and formal. If you are using a text editor like one of the ones I suggested at the start of this tutorial then getting your indentations correct is easy on every keyboard we have a magical button called the "tab button" what this will do is move your writing pointer across a number of spaces depending on where you have pressed tab from. To indent a function correctly is simple all you have to do is indent your code inside each new code block, example below and further explaination below. [IMG]http://puu.sh/bA1Mc/6c2d59affc.png[/IMG] Basically for each code block you define you have to press tab for each code block you are writing in, if you are writing in the main code block you only indent once if you are writing inside a code block thats in the main code block then you indent twice etc. As for making your code more understandable try to name things to what they are so they make more sense, example below. [Code] //Lets Compare self.swagjumpmodeon = true; //To self.superJump = true; //Which one do you understand more? The Bottom One? yea though so... //Same goes with function names and anything else that requires naming[/code] So just remember to code your functions correctly especially if you are releasing them! [/spoiler] [B]FAQ[/B] [Spoiler] Q: My Game Freezes On Loading Screen A: This Means You Either Have A Non-Existant Function or A Syntax Error! Q: Connection Interrupted then Freeze when calling a function or spawning in A: This Means You Have A Loop With No Waits [/spoiler][/B] [/QUOTE]
Verification
Post reply
Forums
Gaming
Call of Duty Classics
Call of Duty: Black Ops 2
Call of Duty: Black Ops 2 Mods and Scripts
Call of Duty: Black Ops 2 Scripts
Call of Duty: Black Ops 2 Scripts Questions
Call of Duty: Black Ops 2 Answered Questions
GSC
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