GSC Managed Code List By iTahhr

iTahhr

Well-Known Member
Messages
248
Reaction score
118
Points
243
iTahhr's Managed Code List

NOTE: I do not claim to be the best coder so if i make any mistakes please correct me down below or send me a pm telling me what i could add or improve to this tutorial thread, thanks!

Symbols and includes:
Q: What is symbols and includes?
A: Symbols and includes are useful for if statements and some other stuff.
Examples:
Code:
if(self.origin[0] >= 100)//Checks to see if your origin is the same as "100,342,22"
self iprintln("you're more than or equal to 100");

Symbols and includes:
Code:
> means more than[/LEFT]
< means less than
== means equals
>= means more than or equal
<= means less than or equals
!= means not equal
|| means or
&& means and
Variable:
Q: What are Variables used for?
A: Variables are used to store information.
Examples:
Code:
Variable = "Lets Learn Together";

if(Variable == "Lets Learn Together")
        self iprintln("Continue Code");

Variable:
Code:
Variable = "Lets Learn Together";
Floats and int's:
Q: What are Floats and int's?
A: Floats and ints change Variables to values.
Examples:
Code:
time = strTok(".5,.5,.2,.2,.1,.05", ",");
for(Ext = 0; Ext < 6; Ext++)
{
    wait float(time[Ext]);
}
Int's are used the same way but you only use ints when you aren't using decimals.

Floats and int's:
Code:
float(time[Ext]);
int(time[Ext]);
Strtok:
Q: What are Strtok used for?
A: Strtok is used to store data until it is being called.
Examples:
Code:
So lets make it count to 10, always remember in gsc the first value will always be 0 so if you want to count to 10 you would do, Ext = 0; Ext <9; Ext++ in a loop.
Example = strTok("1,2,3,4,5,6,7,8,9,10", ",");
for(Ext = 0; Ext < 9; Ext++)
{
    self iprintln("Current Num: ^2" + Example[Ext]);
    wait .2;
}

Strtok:
Code:
Example = strTok(" ", ",");

Words/Commands:
Q: Why are these useful?
A: These are usful since you can end loops easily etc.
Examples:
Code:
if(self useButtonPressed())
break;

Words/Commands:
Code:
break; means terminate/end. 
return; means terminate and reurn to called function. 
continue; means continue.

Clean Code:
Q: Why should we clean our code if it works?
A: Clean code means better code since people will be able to read it if you are having issues.
Examples:
Code:
if(self.variable ) //means if true
self iprintln("variable is currently False");

Clean Code:
Code:
if(self.variable ) //means if true
if(!self.variable ) //means if false

1    2
true    false

Fixing Overflows:
Q: Overflows suck but they're hard to fix?
A: Yes overflows do suck but they are simple to fix.
Notes:
Code:
Make sure everything is getting fixed as "player"!
Fixing Values: setValue
Fixing Normal Text: setSafeText

Examples:
Code:
if(isDefined(player.FuncVariableHere))
{
    player.Ext["Tuts"] = setSafeText("Hello CCM");
    player.Ext["MainTut"] = setSafeText("Welcome To...");
}

Fixing Overflows:
Code:
if(isDefined(player.FuncVariableHere))
{
    //Fixing Text Here
}

Fonts:
Q: The default font is good enough?
A: Yes the font is good but you might like a different one better.
Example:
Code:
self.Ext["Txt"] = drawText("Hiya xoxo", "FONT HERE PLEASE!! ", 1.4, "BOTTOM", "BOTTOM", 0, -5, (1,1,1), 3, 5);

Fonts:
Code:
default[/LEFT]
bigfixed
smallfixed
objective
big
small
extrabig
extrasmall

Pressed Buttons:
Q: I leave the buttons the same because they are hard to change?
A: They're not hard to change like you will find out.
Example:
Code:
if(self BUTTONPRESSEDHERE!!())

Pressed Buttons:
Code:
if(self sprintbuttonpressed()) self iprintln("SPRINT");
if(self inventorybuttonpressed()) self iprintln("INVENTORY");
if(self secondaryoffhandbuttonpressed()) self iprintln("SECONDARY OFFHAND");
if(self fragbuttonpressed()) self iprintln("FRAG");
if(self stancebuttonpressed()) self iprintln("STANCE");
if(self jumpbuttonpressed()) self iprintln("JUMP");
if(self meleebuttonpressed()) self iprintln("MELEE");
if(self throwbuttonpressed()) self iprintln("THROW");
if(self adsbuttonpressed()) self iprintln("ADS");
if(self actionslotfourbuttonpressed()) self iprintln("ACTION SLOT FOUR");
if(self actionslotthreebuttonpressed()) self iprintln("ACTION SLOT THREE");
if(self actionslottwobuttonpressed()) self iprintln("ACTION SLOT TWO");
if(self actionslotonebuttonpressed()) self iprintln("ACTION SLOT ONE");
if(self attackbuttonpressed()) self iprintln("ATTACK");
if(self changeseatbuttonpressed()) self iprintln("CHANGE SEAT");
if(self usebuttonpressed()) self iprintln("USE");

Iprintln Buttons:
Q: Sometimes i see people using buttons in text, How can i do that?
A: This is easy, you just need the button codes.
Example:
Code:
self iptintln("Press button [{+usereload}] to activate the mod!");

Iprintln:​
Code:
dpad-up: [{+actionslot 1}]
dpad-down: [{+actionslot 2}]
dpad-left: [{+actionslot 3}]
dpad-Right: [{+actionslot 4}]
X: [{+gostand}]
O: [{+stance}]
Square: [{+usereload}]
Triangle: [{weapnext}]
R3: [{+melee}]
L3: [{+breath_sprint}]
R2: [{+frag}]
L2: [{+smoke}]
R1: [{+attack}]
L1: [{+toggleads_throw}]
L1: [{+speed_throw}]

Colour Codes:
Q: How do i change the colour of things easily?
A: Its simple you will just need the colour code you would like to use.
Example:
Code:
self.Ext["Tut"] = drawText("^1This is colour red", "default", 1.4, "BOTTOM", "BOTTOM", 0, -5, (1,1,1), 3, 5);

Colour Codes:
Code:
^1 = red
^2 = green
^3 = yellow
^4 = blue
^5 = light blue
^6 = purple
^7 = white
^8 is a color that changes depending what level you are on.
American maps = Dark Green
Russian maps = Dark red/marroon
British maps = Dark Blue
^9 = grey
^0 = black

Credits:
iTahhr.
Extinct P.S. Made It Better.​


 
Last edited:

TheNiceUb3r

Veteran
Messages
45
Reaction score
46
Points
793
You can actually set all ur dvars to 1 by default (Which you should define in the first place) with this


Code:
foreach( dvars in strTok( "DVAR-NAMES-HERE,", ",") )
{
if (getDvar(dvars) == "")
{
setDvar(dvars, "1");
}
}
 

The Dark Side

Former Staff Member
Messages
1,012
Reaction score
785
Points
993
You can actually set all ur dvars to 1 by default (Which you should define in the first place) with this


Code:
foreach( dvars in strTok( "DVAR-NAMES-HERE,", ",") )
{
if (getDvar(dvars) == "")
{
setDvar(dvars, "1");
}
}
Code:
Setalldvars(value)
{
foreach( dvars in strTok( "DVAR-NAMES-HERE,", ",") )
{
if (getDvar(dvars) == "")
{
setDvar(dvars, value);
}
}

You could also adapt it to a 0 or 1 like so. :grinning: Havent tested, but it should work. :smile:
 

iTahhr

Well-Known Member
Messages
248
Reaction score
118
Points
243
Code:
Setalldvars(value)
{
foreach( dvars in strTok( "DVAR-NAMES-HERE,", ",") )
{
if (getDvar(dvars) == "")
{
setDvar(dvars, value);
}
}

You could also adapt it to a 0 or 1 like so. :grinning: Havent tested, but it should work. :grinning:
thanks for posting ill update soon :grinning:
 

swoon

Entrepreneur
Premium Member
Messages
492
Reaction score
351
Points
698
You guys should be thankful actually. Even if it's leeched code, it's all in one thread instead of a million others reading so much. And hey, he's trying to do you a favor, the least you guys do is complain about the cons and look at the pro's. Since it's free there should be no hate directed towards him.
 

Procyon

BANNED
Messages
325
Reaction score
119
Points
43
You guys should be thankful actually. Even if it's leeched code, it's all in one thread instead of a million others reading so much. And hey, he's trying to do you a favor, the least you guys do is complain about the cons and look at the pro's. Since it's free there should be no hate directed towards him.
Leched and bad code... Nothing to say thanks about.
 

swoon

Entrepreneur
Premium Member
Messages
492
Reaction score
351
Points
698
Leched and bad code... Nothing to say thanks about.
There's no reason for you to be a douchebag on the forum, is there? Hasn't your mother taught you your manners? Don't say something if it's something not nice? All he's doing is TRYING to help. Sure, anyone could do what he's doing, has anyone yet that keeps it updated? No.
 

Procyon

BANNED
Messages
325
Reaction score
119
Points
43
There's no reason for you to be a douchebag on the forum, is there?
Everyone needs one.
Hasn't your mother taught you your manners?
No she has not.
Don't say something if it's something not nice?
What are you, 12?
All he's doing is TRYING to help. Sure, anyone could do what he's doing, has anyone yet that keeps it updated? No.
Yes; someone has done it, where do you think he got it from?
 

swoon

Entrepreneur
Premium Member
Messages
492
Reaction score
351
Points
698
Everyone needs one.

No she has not.

What are you, 12?

Yes; someone has done it, where do you think he got it from?
Obviously, I'm 12 years old. I still live with my mother and I have an amazing IQ score. No, those are just basic life skills you should've learned. Also, if it's already created, let him do his own thing, instead of bitching and moaning about this one. After all, it's not actually your forum. So you can't do much about it. So complaining gets you nothing.
 
Top