Advanced tutorial 4
Creating a class selector.
I’ll be discussing the newer style, cause it’s far simpler than the older style.
First the basic commands:
1. Selecting a team
A team can be selected with the team command. There are 3 possible teams, with the corresponding commands:
* spectator: team s
* axis: team r
* allies: team b
So if you wanted to make a bind to quickly go spectator e.g. for when your phone rings using your F12 key, it would be like this:
bind F12 “team s”
Or if you enter a server and you want to quickly join axis using F11:
bind F11 “team r”
One important note:
The bind above does not contain a class and weapon choice and thus makes you a soldier with SMG by default.
2. Selecting a class and weapon
A class and weapon can be selected with the class command, which is as followed:
class cls wpn
As you can see the class command is followed by cls, a letter to choose the class and wpn, a number to choose the weapon.
For cls the following options are possible:
* m: medic
* e: engineer
* f: field ops
* c: covert ops
* s: soldier
The number wpn depends on the class you are using. It also depends on the mod you are playing, cause some mods like NoQuarter have additional weapons like the Winchester and Venom. I’ll state all the possibilities per class:
Medic
1: SMG
Engineer
1: SMG
2: Rifle nade
Additional (for mods like NQ):
3: Shotgun (Winchester)
Field ops
1: SMG
Additional (for mods like NQ):
2: Shotgun (Winchester)
Covert ops
1: Sten
2: FG42
3: K43 or M1 Garand
Additional (for mods like NQ):
2: Bar(allies)
Soldier
1: SMG
2: MG42
3: Flamethrower
4: Panzerfaust
5: Mortar
Additional (for mods like NQ):
1: STG44(axis) or Bar(allies)
2: Browning(allies)
4: Bazooka(allies)
5: Granatwerfer(axis)
6: Venom
Now let's say you play medic almost all the time and you want to make 2 binds. One for going medic on the axis team with F11 and one for going medic on the allied team with F12. Using the commands above, that would look like this:
bind F11 "team r; class m 1"
bind F12 "team b; class m 1"
Now let's do an easy example of combining the team and class command with a toggle to make a simple class selector.
Let's say you have 3 favorite classes you always play:
* Medic
* Engy with SMG
* Covert ops with sniper rifle
First you will need a toggle to choose your team, which we will do with F11:
bind F11 "vstr teamSelect"
set axis "set teamSet team r; set teamSelect vstr allies; echo ^0>^7Axis Team Set^0!"
set allies "set teamSet team b; set teamSelect vstr axis; echo ^0>^7Allies Team Set^0!"
set teamSelect "vstr axis"
As you can see, the team is set to a variable called teamSet instead of just executed. And to make clear what I mean by just executed, I did not use the following:
set axis "team r; set teamSelect vstr allies; echo ^0>^7Axis Team Set^0!"
set allies "team b; set teamSelect vstr axis; echo ^0>^7Allies Team Set^0!"
This is because I don't want the team to be set until the class and weapon are also chosen. If I would execute the command team right away and I would be to slow chosing the class and weapon before respawn time is over, I would spawn default as a soldier with SMG. That's why I did not execute it, but set it to a variable teamSet. And the team will be executed by executing the variable teamSet at the same time when the class command is executed.
Now we'll make a toggle to choose the class. This will be done with F12:
bind F12 "vstr classSelect"
set class1 "vstr teamSet; class m 1; set classSelect vstr class2; echo ^0>^7Going Medic^0."
set class2 "vstr teamSet; class e 1; set classSelect vstr class2; echo ^0>^7Going Engineer^0."
set class3 "vstr teamSet; class c 3; set classSelect vstr class2; echo ^0>^7Going Covert Ops^0."
set classSelect "vstr class1"
As you can see, the team is set with vstr teamSet right before the class command is executed. This way team and class are set.
You could say it's finished now, but there is just one line missing. The initial value for the variables teamSelect and classSelect are set, but not for the variable teamSet. If someone tries to choose a class before he/she has chosen a team, it won't work. By setting an echo message to the teamSet variable as an initial value, the user can be warned that he is trying to choose a class before he/she has chosen a team. This should be as followed:
set teamSet "echo ^0>^7You have not chosen a team yet^0!"
We now have the complete script. Here it is in total with comment lines added:
//Binded keys
bind F11 "vstr teamSelect"
bind F12 "vstr classSelect"
//Team select
set axis "set teamSet team r; set teamSelect vstr allies; echo ^0>^7Axis Team Set^0!"
set allies "set teamSet team b; set teamSelect vstr axis; echo ^0>^7Allies Team Set^0!"
set teamSelect "vstr axis"
//Class select
set class1 "vstr teamSet; class m 1; set classSelect vstr class2; echo ^0>^7Going Medic^0."
set class2 "vstr teamSet; class e 1; set classSelect vstr class2; echo ^0>^7Going Engineer^0."
set class3 "vstr teamSet; class c 3; set classSelect vstr class2; echo ^0>^7Going Covert Ops^0."
set classSelect "vstr class1"
//Error message
set teamSet "echo ^0>^7You have not chosen a team yet^0!"
As you can see the commands team and class are fairly easy to use. You can make the class selector as extensive (and complicated) as you want. In the download section you can find the Class selector new style. Studying this class selector, will give you even more insight in creating a proper class selector. This file uses every class and weapon available.
|