ItsMods
[Tutorial] Basic GSC Coding: Making your second code - 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: Making your second code (/Thread-Tutorial-Basic-GSC-Coding-Making-your-second-code.html)



Basic GSC Coding: Making your second code - Yamato - 04-06-2012

Hello

This is the second tutorial about making your first codes. In this one Ill show you how to make a code that shows your position ( can be used to make map edits ) and also something that makes you jump when you go into water.

Lets call our first function CoordinateFinder():

Code:
CoordinateFinder() { //codes will go here }

Now well add a "while" command to keep the game showing your position, and then well add a command which will print our origin:

Code:
CoordinateFinder() { while( 1 ) { self iPrintLnBold( self getOrigin() ); //iPrintLnBold prints a text on the center of your screen, getorigin gets your origin wait 2; //frequency (each 2 seconds it will say your position } }

Lets improove a bit the code so when we die or disconnect the "while" stops to prevent bugs:

Code:
CoordinateFinder() { self endon( "death" ); //endon(something) makes that the game will stop that function when that event(something) occurs self endon( "disconnect" ); while( 1 ) { self iPrintLnBold( self getOrigin() ); //iPrintLnBold prints a text on the center of your screen, getorigin gets your origin wait 2; //frequency (each 2 seconds it will say your position } }

Lets make the other script.

Code:
JumpInWater() { self endon( "death" ); self endon( "disconnect" ); self.trace = undefined; //lets add this variable to avoid a unitialized variable error later. for( ; ; ) //we can also use a "for" instead of a "while" { self.trace = bulletTrace( self getEye(), self getOrigin() - ( 0, 0, 60 ), false, self ); //geteye gives the position of your players eye, the - 0, 0, 60 means that I reduce in 60 units the players position in z axis, the rest: check bullettrace tutorial if( self.trace[ "surfacetype" ] == "water" ) //explained in bullettrace tutorial self setVelocity( ( 0, 0, 600 ) ); //setvelocity pushes a player with the vector we define wait 0.5; } }

So, in total we have this 2 functions:

Code:
CoordinateFinder() { self endon( "death" ); //endon(something) makes that the game will stop that function when that event(something) occurs self endon( "disconnect" ); while( 1 ) { self iPrintLnBold( self getOrigin() ); //iPrintLnBold prints a text on the center of your screen, getorigin gets your origin wait 2; //frequency (each 2 seconds it will say your position } } JumpInWater() { self endon( "death" ); self endon( "disconnect" ); self.trace = undefined; //lets add this variable to avoid a unitialized variable error later. for( ; ; ) //we can also use a "for" instead of a "while" { self.trace = bulletTrace( self getEye(), self getOrigin() - ( 0, 0, 60 ), false, self ); //geteye gives the position of your players eye, the - 0, 0, 60 means that I reduce in 60 units the players position in z axis, the rest: check bullettrace tutorial if( self.trace[ "surfacetype" ] == "water" ) //explained in bullettrace tutorial self setVelocity( ( 0, 0, 600 ) ); //setvelocity pushes a player with the vector we define wait 0.5; } }

To execute them simply add this after the player spawn as I did on the previous tutorial:

Code:
self thread CoordinateFinder(); self thread JumpInWater();

I hope you have learnt something new, the next tutorial will be a bit more advanced (in lenght)

@Yamato


RE: Basic GSC Coding: Making your second code - Bloodfocus - 04-06-2012

Awesome very usefull ,)


RE: Basic GSC Coding: Making your second code - alvarogt95 - 04-08-2012

wow ty dude i learning alot of them


RE: Basic GSC Coding: Making your second code - Bloodfocus - 12-26-2012

Dude , i dont know what this do and how they know the geometruy of each funct , see :

Example:
toggle()
{
self endon("death");
vec = anglestoforward(self getPlayerAngles());
center = BulletTrace( self gettagorigin("tag_eye"), self gettagorigin("tag_eye")+(vec[0] * 200000, vec[1] * 200000, vec[2] * 200000), 0, self)[ "position" ]; //wtf that means and how i can know the bullettrace that im looking for...
level.center = spawn("script_origin", center);
level.lift = [];
h=0;k=0;
origin = level.center.origin;
for(i=0;i<404;i++)
{
if(i<=100)
level.lift[k] = spawn("script_model", origin+(-42,42,h)); //how i can make an object spawn in front of me without laggin me out?
else if(i<=201 && i>100)
level.lift[k] = spawn("script_model", origin+(42,42,h-2777.5*2));
else if(i<=302 && i>201)
level.lift[k] = spawn("script_model", origin+(-42,-42,h-5555*2));
else if(i<=404 && i>301)
level.lift[k] = spawn("script_model", origin+(42,-42,h-8332.5*2));
level.lift[i].angles = (90,90,0);
h+=55;
k++;
}


RE: Basic GSC Coding: Making your second code - Yamato - 12-26-2012

What?


RE: Basic GSC Coding: Making your second code - JariZ - 12-26-2012

l2[ code ]


RE: Basic GSC Coding: Making your second code - Bloodfocus - 12-27-2012

sorry dudes , i was saying :
how i can make a care package shot something?
how i can make that when the care package shot 3 times the care package get delete?

Can someone help me plis?


RE: Basic GSC Coding: Making your second code - Yamato - 12-27-2012

(12-27-2012, 09:17)Bloodfocus Wrote: sorry dudes , i was saying :
how i can make a care package shot something?
how i can make that when the care package shot 3 times the care package get delete?

Can someone help me plis?

Make it shot a magicbullet from its position to the thing you want to shot


RE: Basic GSC Coding: Making your second code - Bloodfocus - 12-27-2012

No se como se hace eso , no me lo podes hacer vos porfavos dude?


RE: Basic GSC Coding: Making your second code - Yamato - 12-28-2012

(12-27-2012, 21:33)Bloodfocus Wrote: No se como se hace eso , no me lo podes hacer vos porfavos dude?

http://www.itsmods.com/forum/Thread-Tutorial-Magicbullets-and-Radius-Damages.html