Recreating the topic i had on the good old forums in our past since i'm bored.
This entire post is focused on 1 command that allows us to make these little "scripts". the "vstr" cvar allows us to create shortcuts.
"vstr: Identifies what follows it as a variable string, used for scripting."
The amount of different things you can do with this command are huge (you can create a script that is able to do trickjumps for example) and is a fun thing to mess around with.
Vstr can also be used as +vstr making into a toggle which can be used to make a script that allows us to shoot and sprint with the press of 1 button.
Simple use of the +vstr command.
- Spoiler:
bind mouse1 "+vstr shootON shootOFF"
set shootON "+attack; +sprint"
set shootOFF "-attack; -sprint"
First line: we bind a key to execute our +vstr cmd, and tell it the names of the commands we want it to run. Do not put a semicolon inbetween the first and second command name, separate them with a space instead.
Second line: we tell the game what to do as long as the button is pressed
Last line: we tell the game what to do if the button is released
So as mentioned before, the + infront of the vstr makes it into a toggle meaning when we press and hold the button (mouse1 in this case) the game will "load" the shootON command we made. Resulting in a sprint while shooting. Letting go of the button will stop the shooting and sprinting.
Now, onto vstr without our +. This script here is an example of how to use it to toggle between options, changing our pmove_fixed to 1 or 0. You can choose whatever you want to define the vstr command, you don't need to use pmove1 if you're making a pmove toggle script, you can name it ilovebigpencils if you want...
Sentences in red are added to make it easier to explain so don't copy those if you wish to use this.
- Spoiler:
echo ^xP^wmove_fixed toggler ^1enabled
Echo's that the config has been loaded for confirmation. This line can be ignored.
bind p "vstr pmove"
unbind o
Binding the P key to toggle between options and unbinding O because i use it for other scripts and i don't want things to get messed up.
set pmove "vstr pmove1"
Defining what "pmove" is, in this case it executes pmove1.
set pmove1 "echo ^xP^wmove ^1 1; pmove_fixed 1; set pmove vstr pmove2"
Defining what pmove1 is, in this case it echo's that pmove_fixed 1 has been set and also sets our pmove toggle to execute pmove2 the next time we press P
set pmove2 "echo ^xP^wmove ^1 0; pmove_fixed 0; set pmove vstr pmove1"
Same as above with different value's.
Note: Always jump back to the first vstr command so you can continuously toggle between the 2 options.
Another thing you can do is have 2 buttons to choose an option and then select it.
Next example is a name changer.
- Spoiler:
echo ^xN^wame changer ^1enabled
Echo to confirm script was loaded properly.
bind o "vstr switch"
bind p "vstr select"
Binding our O key to switch options and our P to select the options.
set switch "vstr name1"
set select "vstr setname1"
Defining the commands
set name1 "echo ^xN^wame ^x#^wAxE^x|^wGhostcarrot; set switch vstr name2; set select vstr setname1"
set name2 "echo ^xN^wame Ghostcarrot; set switch vstr name3; set select vstr setname2"
set name3 "echo ^xN^wame ^0<|^1FAT^0|>^1Ghostcarrot; set switch vstr name4; set select vstr setname3"
set name4 "echo ^xN^wame ^x#^wMLP^x|^wGhostcarrot; set switch vstr name5; set select vstr setname4"
set name5 "echo ^xN^wame ^wSparklez; set switch vstr name6; set select vstr setname5"
set name6 "echo ^xN^wame ^wPencil; set switch vstr name7; set select vstr setname6"
set name7 "echo ^xN^wame ^xBlack; set switch vstr name8; set select vstr setname7"
set name8 "echo ^xN^wame ^wDonor; set switch vstr name9; set select vstr setname8"
set name9 "echo ^xN^wame ^x|^wvVv^x|^wGhostcarrot; set switch vstr name1; set select vstr setname9"
Setting the options, echoing the current selection and changing the O key to select the next name in line.
set setname1 "name ^x#^wAxE^x|^wGhostcarrot"
set setname2 "name Ghostcarrot"
set setname3 "name ^0<|^1FAT^0|>^1Ghostcarrot"
set setname4 "name ^x#^wMLP^x|^wGhostcarrot"
set setname5 "name ^wSparklez"
set setname6 "name ^wPencil"
set setname7 "name ^xBlack"
set setname8 "name ^wDonor"
set setname9 "name ^x|^wvVv^x|^wGhostcarrot"
Setting the names for each option.
Note: since this is a toggle remember to change the switch key back to the first option.
Learning the vstr command is all about messing around and testing things, trial and error. You should be able to look at these scripts and teach yourself the rest of scripting. If something is unclear (very certain it is since i'm rushing this... i need to pee badly) just post and i'll try to clear it up.