Welcome!

By registering with us, you'll be able to discuss, share and private message with other members of our community.

SignUp Now!

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

sunstep

Truly Feared
Joined
Jun 15, 2020
Messages
164
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"
    "vscripts"       "file.nut OR foldername/file.nut OR foldername/subfoldername/filename.nut etc."
}

Do NOT include tf/scripts/vscripts to the vscript key.
VSCRIPTS ARE ALWAYS SEARCHED FOR STARTING IN THE TF/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 to run a certain function in the vscript code:

Code:
{
    "classname"         "logic_relay"
    "targetname"        "whatever" <-- Not necessary, if you use OnSpawn
    "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: You will require a dedicated server to be able to do this.

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:

1672016873079.png


Do this instead:

1672016876989.png


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.
 
Last edited:

Who Read This Thread (Total Members: 11)

User Who Replied This Thread (Total Members: 1)

Top Bottom