100% found this document useful (1 vote)
497 views17 pages

CFG Scripting Guide for MW2/IW4x

detailed MW2 CFG Scripting Tutorial by phen6m

Uploaded by

chinapoet24911
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (1 vote)
497 views17 pages

CFG Scripting Guide for MW2/IW4x

detailed MW2 CFG Scripting Tutorial by phen6m

Uploaded by

chinapoet24911
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1

CFG Tutorial by phen6m


2

Table of Contents

Overview……………………………………………………………………………………...… 3

Setup…………………………………………………………………………………….……… 4

Setting a Script to a Button………………………………………………………………....… 5

How to Combine Scripts…………………………………………………………………….… 6

All the Buttons in .cfg Language ..…………………………………………………………… 7

Scripting Full Shots……………………………………………………………………………. 8

DVARS………………………………………………………………………………………….. 9

How to Add Spins……………………………………………………………………………...10

How to Add Varials in Spins…………………………………………………………………..11

Utilizing Spins to Your Advantage (Movement)………………………………………….... 12

Run Out of Room for Script?………………………………………………………………... 14

Scripting in Lag……………………………………………………………………………..… 15

How to Organize Scripts in CFG File……………………………………………………..…16

Custom DVARS……………………....……………………………………………………..…17
3

Overview - CFG (MW2/IW4x)

Config, or CFG is an internal game language, to keep it simple. CFG is mainly used for
setting controller settings, and changing game settings. Essentially, when it comes to
trickshotting, we are telling the game what we want it to do.

Advantages to .cfg scripting over cronus:


- Free
- Internal (more accurate in general and during lag)
- Access to DVARS
- Scripts can be stored in 1 .cfg file
- Scripts are not character limited

Disadvantages to .cfg scripting over cronus:


- Zoomloads (inc. burst)
- Wildscopes
- Anything outside of the game itself

Note: Learning this will take time. I’ve been using .cfg scripts for over 6 years now, but it
took me over a year to get comfortable with them. Basically, don’t get too frustrated to
start.

[Link]
[Link]
4

Setup

MW2/IW4X - Place the .cfg file in the “players” folder inside your IW4x game files.

Your .cfg file will contain all of your scripts. Make sure you can easily access this file. I
personally have a shortcut right to the file on my desktop. You can name the cfg file
whatever you want.

Next step is to bind an exec to the .cfg file. Once IW4X is open, open console using the
~ button. Type the following:

/bind BUTTON “exec NAMEOFCFGFILE”

Blue = The button you want to exec the .cfg file.


- “exec” or execute, basically means that you are toggling/updating the .cfg file.
Red = The name of the cfg file.

Examples:

/bind DPAD_RIGHT “exec buttons_default”


/bind P “exec buttons_default”

Every time you make a change to your scripts in your .cfg file, save the file, then press
the button you binded the exec to. This will update it. Saving the .cfg file and not exec it
will result in the game using the latest exec version of the script.
5

Setting a Script to a Button


So lets say I wanted to set the pre-made Intervention reload nac script to DPAD_LEFT.

set InterventionReloadNac "+reload;-reload;wait 36;weapnext"

Here in red is the name of the script. Everything in the ”GREEN” is what that script will
do. It does not matter the name of the script (in red), it is just nice to keep things
organized with appropriate names. To set this to DPAD_LEFT, or your button of choice,
you will open console (~), and type the following; for example:

/bind DPAD_LEFT "vstr InterventionReloadNac"

Make sure you DON’T remove the “vstr” or any of the “ “ or it will not work. Also make
sure that the name of the script (red) is spelled the SAME for each step. Any misspelling
will result in the script not working.

Once those steps are successfully completed, everything in green (in this case, an
Intervention reload nac), will be performed on the press of DPAD_LEFT.

You can bind multiple scripts to multiple different buttons, however you cannot bind two
scripts to one button. You will need to combine the two scripts into one in order to do
that.

That is your basic setup. Next, you will learn how to begin scripting combos.
6

How to Combine Scripts


First let’s understand what is happening with each code.
Let's look at an example:

set Kar98kAdalia "+reload;-reload;wait 50;+forward;+breath_sprint;wait


10;-forward;-breath_sprint”

For an adalia, as you would guess, you reload, wait a certain amount of time, then
sprint. That is all we want the code to be doing. Read what is in the "(the script)" .
+reload is reload; this needs to be followed by -reload so it stops holding reload. There
is then a “wait 50” which is the unit of time between the +reload;-reload, and the next
action. The next action is the sprint. +forward;+breath_sprint is sprint. (This once agains
needs to be met with a -forward;-breath_sprint to tell the code to stop sprinting). In this
example, we will sprint for 10 frames(wait 10), before it stops and the script is complete.

To combine scripts; let's say we want to combine the kar adalia with the kar reload nak.
Here is the script for the kar reload nak:

“+reload;-reload;wait 48;weapnext”

To combine these, is very simple. In orange is the Kar adalia, and in purple is the reload
nac,

“+reload;-reload;wait 50;+forward;+breath_sprint;wait 10;-forward;-breath_sprint;wait


10;+reload-reload;wait 48;weapnext”

As you probably noticed, I put a “wait 10” in between them. A unit of time needs to go in
between both scripts so they are not being done immediately after one another. “wait
10” is not a lot of time, that is what I use in this example, but it all depends on
preference. To make this script more complete, I will add a sprint yy at the end of it
(blue).

“+usereload;-usereload;wait 50;+forward;+breath_sprint;wait
10;-forward;-breath_sprint;wait 10;+usereload-usereload;wait 48;weapnext;wait
15;+forward;+breath_sprint;weapnext;wait 5;-forward;-breath_sprint;weapnext”

Essentially, you’re telling the game what you want it to do. You have to think about what
each combo or glitch etc. is doing, and how you would write that in .cfg language.
7

All the Buttons in .cfg Language

Shoot = +attack
Aim in = +speed_throw
Lethal = +frag
Tactical = +smoke
Knife = +melee
Sprint Button = +breath_sprint
Jump = +gostand
Crouch = +stance OR gocrouch
Prone = +stance OR goprone
Reload = +reload OR +usereload
Switch Guns = weapnext
Forward = +forward
Moveleft = +moveleft
Back = +back
Moveright = +moveright
DPAD Up = +actionslot 1
DPAD Down = +actionslot 2
DPAD Left = +actionslot 3
DPAD Right = +actionslot 4
Start Button = togglemenu
Spin Right = +right
Spin Left = +left
Look Up = +lookup
Look Down = +lookdown

Once again, anything with a + infront of it MUST have a - . Think of it like this. When a code
reads +reload, for example, it will keep holding that button until it meets -reload.

The following script will hold reload button for 50 frames:

“+reload;wait 50;-reload”

Buttons like weapnext or goprone do not need a -.


8

Scripting Full Shots


Once you are good at combining multiple scripts, you can now begin scripting full shots.
The biggest thing about scripting full shots is adding the jump.

Since you are unable to use any buttons while a script is in progress, you are unable to
jump. This means that we have to add a jump in the script. You need to identify a
location in the script to jump. Be careful choosing this location, because you want to
make sure that you are not landing, or too high in the air. That decision is up to you, and
is something that will improve with experience.

One concern with jumping, is that you need to cover distance so you can actually jump
off a roof top or whatever the hell it is you’re jumping off. We need to add a movement.
Here is a list of all the movements: +forward, +moveleft; +back; +moveright. Each of
these, of course, needs to be followed up with a - version of it. I recommend you make
room for 10 units of time while moving before you jump, like “+forward;wait
10;+gostand;-gostand;-forward,” for example. This all depends on which way you need
to jump.

Since we are keeping it simple, let’s use the same example script from the end of the
previous page. This isn’t the best example, but it’s not too complicated to figure out how
to do this in NSL shots.

“+reload;-reload;wait 50;+forward;+breath_sprint;wait 10;-forward;-breath_sprint;wait


10;+reload-reload;wait 8;+forward;wait 10;+gostand;-gostand;-forward;wait
20;weapnext;wait 15;+forward;+breath_sprint;weapnext;wait
5;-forward;-breath_sprint;weapnext”

In red is the jump.


In cyan is the reload nac script from earlier….

It’s important to make sure that you don’t change any of the timings. I added jump in
during the reload nac. Since it is in the middle of the reload nac, notice how there is still
a total of wait 48 between the +reload and the weapnext (nac)? I understand I could
have added it during the adalia, but for the sake of a good example, that’s why I added
it where I added it.

Once again, +forward can be changed with +back, +moveright, or +moveleft; whichever
direction you need to jump.
9

DVARS
The main advantage of cfg over cronus.

The DVAR I want to discuss is gravity; (g_gravity 800), but keep in mind that all other
DVARS work in very similar fashion. Gravity is very useful. Setting it to a lower value
gives you more air time in your shots. 800 is default value. I recommend not going any
lower than 500. You can incorporate this in your shot like this:

set Kar98kAdaliaRnak “g_gravity 600;+reload;-reload;wait


50;+forward;+breath_sprint;wait 10;-forward;-breath_sprint;wait 10;+reload-reload;wait
48;weapnext;wait 15;+forward;+breath_sprint;weapnext;wait
5;-forward;-breath_sprint;weapnext;g_gravity 800”

I put it at the start, so the script is executed under gravity 600, but when it ends, it resets
to default value. I recommend you get in a habit of setting the DVARS back to their
default value after the script with all the DVARS you use. Here are a list of other useful
dvars that I use in a very similar fashion to gravity.
- g_speed 200
- player_useRadius 128
- sv_padpackets 0
- jump_height 40
g_speed is how fast you move. This is helpful for your jump, if, for example, you need to
jump farther. Once you get more advanced, this will be a key DVAR to shots that involve
movement.

Once again, all DVARS work in similar ways. Here is a link to 1,733 MW2 DVARS:

[Link]
10

How to Add Spins:


First we need to understand the basics of yawspeeds. Since +right only spins you at something
like 4 sensitivity, we need to use yawspeeds. Yawspeeds are basically how fast you spin.
Unfortunately, what makes this complicated is that there is no gradual build up to top spin
speed, like there is if you were to spin normally on high sensitivity, so I had to fabricate/replicate
what that would be. This makes it slightly difficult for us to add in a shot because we have to
keep all the numbers constant or it will look bad.

Here is the basic script:

set Spin "+right;cl_yawspeed 50;wait 3;cl_yawspeed 100;wait 4;cl_yawspeed 200;wait


3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait 3;cl_yawspeed 925;wait 57;cl_yawspeed
650;wait 3;cl_yawspeed 350;wait 3;cl_yawspeed 200;wait 3;-right"

This is the script for spins.

There are two parts to this script. The part in blue text is start spin, and the orange text is end
spin. You can technically do something like “+right;cl_yawspeed 925,” but it will look bad
because there is no gradual “build up” to max sensitivity, likewise how there is a gradual slow
down when you stop. It’s difficult to explain what I mean, but when you are playing on 10 sens
and you spin, you don’t automatically start spinning at 10 sens. You have a slight build up into
10 sens.

In red, is “wait 57.” This number has no meaning, but is there to represent the time spinning at
full speed (or yawspeed 925 in this case). In case you’re wondering, if you were to run that very
script, it should do a perfect 540. I originally made this script for my roundhouse ladder clip,
which is why I never bothered to change wait 57 to a more meaningful placeholder like 100.

Example:

set Kar98kAdaliaRnak "+reload;-reload;wait 10;+right;cl_yawspeed 50;wait 3;cl_yawspeed


100;wait 4;cl_yawspeed 200;wait 3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait
3;cl_yawspeed 925;wait 26;+forward;+breath_sprint;wait 10;-forward;-breath_sprint;wait
10;+reload-reload;wait 48;weapnext;wait 15;+forward;+breath_sprint;weapnext;wait
5;-forward;-breath_sprint;weapnext;wait 10;cl_yawspeed 650;wait 3;cl_yawspeed 350;wait
3;cl_yawspeed 200;wait 3;-right"

It’s important to note how I added the spins in while not messing with either the adalia timing
(between the +usereload;-usereload and +forward;+breath_sprint), or the spin scripts
themselves. It’s easy math, subtract the total spin time from the build up from the wait time you
are interrupting.
11

How to add Varials in Spins


Adding varials is very difficult, and I highly recommend not worrying about them if you
are not comfortable with basic spins.

You may have noticed that +lookup and +lookdown don’t work with yawspeeds, and
move you at a snail’s pace. Like how yawspeed is to +right, we will use pitchspeeds for
+lookup and +lookdown.

Here is an example of a varial I have scripted.

set Varial "+lookup;cl_pitchspeed 100;wait 4;cl_pitchspeed 200;wait 4;cl_pitchspeed


250;wait 55;cl_pitchspeed 200;wait 4;cl_pitchspeed 100;wait 4;-lookup;+lookdown;wait
4;cl_pitchspeed 200;wait 4;cl_pitchspeed 250;wait 33;cl_pitchspeed 200;wait
4;cl_pitchspeed 100;wait 4;-lookdown"

The trick with these, as always when it comes to spins, is to make transitions smooth.
This will take time and practice. It will also make your scripts very large.

In red I have the “build up” to top speed for both the +lookup and +lookdown
In yellow is the “build down”
In cyan is the time looking up/down at top speed.

You can of course combine this with a left or right spin, but this is just the vertical
movement for now.
12

Utilizing Spins to Your Advantage


(Movement):
Overview:

Movement - Literally anything that requires critical/very specific movement, such as


jumping out a window while spinning, or moving to a certain location during spins.

Tip: Change movement DVARS, such as g_speed, g_gravity, jump_height,


ladderpushvel, etc to make it easier on yourself!

Start with a Location


- When it comes to shots to require movement, such as a window bolt, you need to
identify a definitive location to start from so your script will be accurate and
consistent.
- What I do once I find my location, I print my coords/angles in the killfeed with my
menu, then write the coords/angles in a load location script. Pinpoint accuracy
goes a long way with scripting.

Let’s say we are scripting movement for a window bolt, for example. This example also
applies to boltstalls, bolt movement or anything that requires critical accuracy with
movement.

Start with the first part of the spin script like so:

+right;cl_yawspeed 50;wait 3;cl_yawspeed 100;wait 4;cl_yawspeed 200;wait


3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait 3;cl_yawspeed 925;wait 60;-right

Do however many spins you want to do on ground, then jump into the window. In this
example, change the wait 60 to whatever it needs to be in order for you to be facing the
window you want to jump in. Let’s say wait 60 works and has you facing the window.
Add your jump on wait 60 like this:

+right;cl_yawspeed 50;wait 3;cl_yawspeed 100;wait 4;cl_yawspeed 200;wait


3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait 3;cl_yawspeed 925;wait
50;+forward;wait 10;+gostand;-gostand;-forward;wait 5;-right

NEXT PAGE ...


13

The “wait 5” is an addition in between the jump and the -right because it will make the
jump more accurate once you add the latter part of the spins. I don’t know how to
explain this. Trust me with this one.

This will most likely either jump too early or too late by a little. Make appropriate
adjustments to the wait time. If you over or under shoot the jump, change g_speed
DVAR.

Once you land on the window, change the “wait 5” to a higher number. The goal with
this “higher number” is to stop spinning around when you land on the window. Make
sure the jump is consistent. You should be getting it at least 90% of the time if you did it
good.

Now is the tedious part. Keep adding 5 to the end wait time. Each time you run the new
script, check what direction you need to move toward at that specific time. Make those 5
units of time move you in the direction you need to move until you reach a position in
which you can jump out the second window. *remember you can change how fast you
move with g_speed*

Once at the second window, do the same thing as you did jumping in the first window.

Lastly, incorporate a combo into the movement WITHOUT changing any of the
movement times. VERY IMPORTANT! It will be hell if you fuck this up and don’t have a
backup of the raw movement script saved.
14

Run Out of Room for Script?


When you start scripting spins and movement, you are going to run into this problem. I
personally have had to make a shot with 6 different lines of code before.

If your script is so long that it automatically goes down to the next line, you have a
problem. The script will only run what is on the first line, and disregard what’s on the
rest.

To fix this, you need to make the one long script, into two shorter ones. Take the part
that has overflowed onto the next line, and some of the script on the first line, and make
it a new script. Then place “vstr NAMEOFNEWSCRIPT” at the end of the first one.

Example (Let’s say the orange part of code doesn’t fit on one line):

set Spin "+right;cl_yawspeed 50;wait 3;cl_yawspeed 100;wait 4;cl_yawspeed 200;wait


3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait 3;cl_yawspeed 925;wait 57;cl_yawspeed
650;wait 3;cl_yawspeed 350;wait 3;cl_yawspeed 200;wait 3;-right"

-------------------------------------------------------------------------------------------------------------------------------

Do This :

set Spin "+right;cl_yawspeed 50;wait 3;cl_yawspeed 100;wait 4;cl_yawspeed 200;wait


3;cl_yawspeed 400;wait 3;cl_yawspeed 650;wait 3;cl_yawspeed 925;vstr Spin2”

set Spin2 ““wait 57;cl_yawspeed 650;wait 3;cl_yawspeed 350;wait 3;cl_yawspeed 200;wait


3;-right”

As you see in pink, the script was expanded to two codes. Running “Spin” will result in “Spin2”
running at the end of “Spin” because that code is exec at the end of Spin.
15

Scripting in Lag
Lag is weird. That’s basically it.

The biggest thing to take away from this page is that sometimes scripts that normally
work without lag, don’t work in lag. This is to be expected when you venture into the
land of skrees. I recommend making your own section of scripts titled “Lag.”

Things to note:
- sv_padpackets DVAR gives lag.
- sv_padpackets 35000+ = AIDS
- sv_padpackets 20000+ = 1 bar
- sv_padpackets 9000 = 2 bar
- DVARS are delayed. Once a DVAR is read in the script, there will be delay, like
always with lag. This, however, is not present in killcam. DVARS register normally
in killcam.
- Use +reload over +usereload. For whatever reason, +reload has no delay in ANY
amount of lag.
- Use +usereload when scripting skrees. Skrees are normal nac time -2. Then add
+usereload;-usereload;wait 2;weapnext. The +usereload makes the weapnext an
illusion.
- A skree is an illusion. Think of it as a fake nac. The game thinks you did a normal
nac, until the game catches up to itself. If you want to do something during a
skree, treat the skree like a normal nac.
16

How to Organize Scripts in CFG File


This is certainly a personal preference thing, but I do have some tips.
You can write text in the file for organizational purposes like so …

//Snipers
//Pistols

Etc. So long as it has two //, it will be ignored.

I generally put all my single nac scripts under each category of gun. If I need an
Intervention Skree, then Ican go down to //Snipers and find it there. I also recommend
putting all your useful script/DVARS at the top of the screen, so you can easily tweak
them around.

Heres an image of my .cfg file, and it’s organization. In the blurred part are useful scripts
I tend to use a lot. The blank space is where I will mess around with new scripts.
17

Custom DVARS
The last thing we are going to talk about is custom DVARS. These are made via GSC
code; part of your mod menu. Here are some examples of custom DVARS In my menu.

+spot (Loads exact coordinates)


+repeater (Fake Repeater)
+prone (Auto-Prone)
oma 1 (OMA to class 1)
class 1 (CCB)

These custom DVARS run GSC code. They are often very useful.

Thing to note:
- These work like normal DVARS
- Don’t work well in lag
- Must be threaded in GSC menu

If you don’t know how to work GSC, or don’t have a menu that has custom DVARS,
you’re out of luck for this one.

You might also like