This tutorial should teach you the basics of making your own vstrs. It is preatty easy, if only you understand what the vstr is. Because of this the first 3 paragraphs are here to introduce you to the theory. If you think you don't need it - you may omit them.
Configuration (.cfg ) filesEdit
Everything you change in your settings, be it your name, any variable like
/snaps 80, your saber or your binds, this all is saved in a temporary .cfg file called jampconfig.cfg (Jedi Academy Multi Player Configuration). This file is executed (loaded) automatically each time you start a game. Each time you change something in game or in your gamedata folder this file will be auto-modyfied by the game and data from it may get lost.
That's why players often create their own config files using
/write name.cfg command
So what is this file that we save? It is in fact a set of instructions that are being executed each time we load them, saved in a simple .cfg file (You can open it with notepad like a simple text file. Also any .txt file can be turned into.cfg one - just change its extension from .txt to .cfg ).
Now, what if we want something to be executed later, not at the moment of executing .cfg file? For example a set of commands we define ourselves? Such set may be "Login on clanchat. Wait for 2 seconds. Set team chat to clanchat. Wait another second. Say "hello guys!" ".
Such sets, which we can execute ourselves scince they are loaded, are so called "variable strings". In short: vstrs
So, how can we define what vstr is? It is a set of commands you can load and execute anytime after.
The configuration file when executed (/exec name.cfg) will load all its content. If it contains vstrs the vstrs will be loaded as well, but loaded vstrs doesn't change anything unless they are executed themselves.
Look at the example: Let's say we have .cfg file "johny.cfg" with our name, binds and all stuff there. And let's say it also contains a vstr called "login" logging us on clanchat and saying 'hello'.
- We go on server.
- We use
/exec johny.cfg. All our stuff gets loaded.
- Now we use
/vstr login. We got logged on clanchat and we say 'hello'.
Pay attention though, as we aren't forced to login and say hello :) For example if we go no other clan server we will not want to do this. In this case we just don't use our vstr and all is cool.
Utility of vstrsEdit
As you probably just thought- on client side vstrs haven't got much good usage. Probably the only one is making text-saying help scripts. Instead of making a vstr you had better create a multi-bind (see: Multi-binding). In this case vstrs are useful only when you need to execute multiple commands and don't want to bind them.
On Server side, however binds doesn't exist. Server doesn't have keyboard after all :P Thats why on Server side vstrs are much more useful. Using command
/amvstr <vstr name here> even admins without rcon may tell server to do execute some of its vstrs. This way even not knowing advanced server cvars you may activate all weapons on server, modify Force settings, change timelimit and do much more advanced operations, all via one command!
How to make vstrEdit
As you might have seen the .cfg file is everlasting mess of commands like
[...]seta cl_yawspeed "750" bind c "say ^1Good ^3Game!"[...]
Let's explain what all this serve for:
setais used to give values to variables permanently
setis used to give values to variables for the short time (untill you shut the game down)
bindis used to bind something to a key.
waitis used to wait given ammount of miliseconds
echois used to print sth in console
sayis used to say something on chat (on server side we use "svsay" to talk on chat instead)
- semicolon (;) is used to separate commands
- +you can also put ordinary commands like rate 25000 or even kill... if only you wish the vstr to kill you :P
To create a vstr just open a text file follow the scheme:
seta <vstr name> "command1;command2;command3;...;command n"
Than save the file as .cfg
seta sayhello "clanpass myclanpass08; wait 2000; say_team mod clan; wait 1000; say ^1hello!"
will make a vstr logging you on clanchat and than saying "hello" to everyone. To execute it firstly exec the cfg file you put it in and than use command
There is 1 more thing you may wish to know about vstrs. You can make vstr that operates on others!
For example you may have 2 vstrs: 1 for switching something on, 1 for switiching off. And you can make third one, which will be used to toggle both of them: On first use it will use 1st of them, on the next use- 2nd, on the third use it will use 1st again.
See how it works:
seta switcher "vstr state1" seta state1 "set switcher vstr state2; <do something here>" seta state2 "set switcher vstr state3; <do other thing here>" seta state3 "set switcher vstr state1; <do another thing here>"
As you might have realised the firstly declared vstr is the "operating" one. The only argument we give to such operating vstr is the name of the vstr it should execute on its first use.
So when used, the switcher will execute vstr state1. State1 vstr will point switcher to state2, so that on the next use switcher will use state2. So when we will use switcher again it will execute state2. On next use- state3 and on the next- state1 again.
It is very simple and nice way of making things easier for ourselves, as we dont have to remember names of all vstrs- we may just have 1 to toggle them!
Look at the example from the real EFF server vstr file:
seta Jvm "vstr jvm_0" seta jvm_0 "set Jvm vstr jvm_1;say ^2Jedi Vs Merc ^5switched off (0);seta g_jediVmerc 0" seta jvm_1 "set Jvm vstr jvm_2;say ^5Classic ^2Jedi Vs Merc (^51^2);seta g_jediVmerc 1" seta jvm_2 "set Jvm vstr jvm_3;say ^5All items for mercs ^2Jedi Vs Merc (^52^2);seta g_jediVmerc 2" seta jvm_3 "set Jvm vstr jvm_0;say ^5Ampowered Vs SuperMerc ^2(^53^2);seta g_jediVmerc 3" seta JvM_start "seta g_weaponDisable 0;seta g_jediVmerc 3;map_restart;say ^2 Gametype set to ^5 Empower vs SuperMerc ^2. Game begins. "
As you see the admin can use
/amvstr jvm to toggle between possible types of Jedi vs Merc. Each time he will be informed which state is chosen at the moment. Each vstr will change the settings and point the operating vstr to the next one.
Additionaly admin can use
/amvstr jvm_start to set default settings and begin Jedi vs Merc right when he types it (as you see jvm_start executes command
map_restart, which will restart the map introducing all changes made so far and instantly starting the JvM slaughter :j )
! ATTENTION: Vstrs names are NOT case-senstive ("JvM" will equal "jvm").