TF2 Using VScript without packing it in the map and bug in hammer++

sunstep

★ Donor ★
May 17, 2020
129
31
98
Lian Yu
Hey there,

I am not really very active anymore on tf2 or games in general, but I recently heard that Team Fortress 2 got VScript support.
That is very good news, in my opinion. Now, the only problem is that there are not too many tutorials available. So I decided to contribute to it myself.
In this guide, I will tell you how you can use VScript without having to pack it in the map. I will also warn you about a bug in Hammer++, that will make VScript not work for you.

VScript without packing it in the map:

To use VScript without packing it in the map (or editing the BSP in any other way), you need to be able to edit the entities in the map without touching the BSP. You can do this in two different ways. The first possible way, is using stripper config. Or you can manually edit the ENT file of the map. For the second way, you need to make sure it only edits the ENT file on the server, and not for the clients, or else the clients will have to download a custom version of the BSP anyway, and that is exactly what we are trying to avoid. For most servers, I recommend the first method.

It does not matter which way you do it, at the end you will have to make the same modifications:
Add a logic_relay to the map, give it a target name, point it to where the vscript is supposed to be.

Example:
Code:
add:
{
    "classname"     "logic_relay"
    "targetname"    "vscript"
    "spawnflags"    "2"
    "vscript"       "file.nut OR foldername/file.nut"
}

Do NOT include tf/scripts/vscripts to the vscript keyname.
VSCRIPTS ARE ALWAYS SEARCHED FOR STARTING IN THE SCRIPTS/VSCRIPTS FOLDER.
So basically:
tf/scripts/vscripts --> This is the base directory, you can't get out of it.
The full directory that you need: tf/scripts/vscripts/you-can-decide-how-its-goes-further.

When entering this OMIT tf/scripts/vscripts, so at the end you only write: you-can-decide-how-it-goes-further in the vscript keyvalue


Example:
vscript is located in /tf/scripts/vscripts/mapname/script.nut
Use the following location: mapname/script.nut

Next, you need to create an output. How you do it is up to you. In this example, we will use a logic_relay:

Code:
{
    "classname"         "logic_relay"
    "targetname"        "whatever"
    "OnSpawn"           "vscript,RunScriptCode,Yourfunction(),0,-1"
}

Now that the map is ready for the vscript, you need to open your (s)ftp program and go to your server directory.

There are two possible places you can put the vscript in. Of course, this has to match the path you specified in the steps above:

1. Possibility one: /tf/scripts/vscripts/<This part is up to you>
2. Possibility two: /tf/custom/Yourfolder/scripts/vscripts/<This part is up to you>. When using the custom folder, make sure that you work in the scripts/ vscripts folder.

Do not be stubborn like me. Due to my stubbornness, I figured out that the two paths above are the ONLY available paths for vscript to work in.

Simply load up the map now, and the vscript should work. At this point, you are still working with the old BSP!

Summary:
1. Create a logic_relay, without modifying the BSP. Give it a targetname and point it to where the vscript will be located on your server. Make sure that you leave out scripts/ vscripts folder from the path, as it will be the base path by default. The only customizable part is the part after scripts/ vscripts.
2. Create an output to execute the script, just like you would do with a normal vscript case.
3. Place the vscript in the server. Use the specified location in the steps above.
4. Reload map if the server is already running.

Note: This is not only meant for server owners, if you are not a server owner, this will work for you as well. The only difference is that you work in your local tf2 folder, while server owners work in a (s)ftp browser.

Bug in Hammer++

When specifying a vscript in hammer++ using the manage list pop up. It will automatically fill out for you where the vscript is located. Unfortunately, this is bugged out. It fills out the wrong location for you. Just like I explained above, you need to omit tf/scripts/vscripts from the path. Or else the server console will fail to find your script. Why is this the case you might be wondering?

Tf2 by default already looks in /tf/scripts/vscripts. So if you tell it to look in /tf/scripts/vscripts/file.nut. It will use this path: /tf/scripts/vscripts/tf/scripts/vscripts/file.nut

Get it now?

To get around this, simply remove the /tf/scripts/vscripts part from the path to your nut file.

Example:

Don't do this:
1672016191671

Do this instead:
1672016324509


If you have any questions about this, feel free to reply to this thread. I will be happy to answer them if I have time.
 

sunstep

★ Donor ★
May 17, 2020
129
31
98
Lian Yu
Edit:

I said the following in the post above:
Note: This is not only meant for server owners, if you are not a server owner, this will work for you as well. The only difference is that you work in your local tf2 folder, while server owners work in a (s)ftp browser.
This is of course wrong, you will need at least a dedicated server to work on, for this to work. So instead of your local tf2 folder, it should be your local tf2 server folder, if you have a server to host the tf2 server on, that will of course work as well.
Post automatically merged:

Edit 2: about the first example:
Code:
{
    "etc"            "...."
    "vscript"        "...."
}

This should be:
{
    "etc"           "...."
    "vscripts"      "...."

(Notice the s at the end of vscripts)
}
 
Last edited:
  • Like
Reactions: Captain Glenavon