Learning Eventscripts: Make stuf download using ES

This tutorial will show you how to make files downloadable.

Ok this tutorial will show you how to add certain materials/models/sounds for a client to download when they join the server.

The benefit of using eventscripts over es tools or mani, is that you can choose what event to add the download and what variables the players have to follow in order to download it.

I will include an example after I get a bit more into it.

Ok so lets begin.

First things first, we want to get the download directory of the materials/models/sounds on the server. For the purpose of this tutorial I will use the directory from the predator model by SLOW:

materials/models/player/slow/predator_camouflaged/devices.vmt
materials/models/player/slow/predator_camouflaged/limbs.vmt
materials/models/player/slow/predator_camouflaged/torso.vmt
materials/models/player/slow/predator_decamouflaged/devices.vmt
materials/models/player/slow/predator_decamouflaged/devices.vtf
materials/models/player/slow/predator_decamouflaged/devices_norm.vtf
materials/models/player/slow/predator_decamouflaged/limbs.vmt
materials/models/player/slow/predator_decamouflaged/limbs.vtf
materials/models/player/slow/predator_decamouflaged/limbs_norm.vtf
materials/models/player/slow/predator_decamouflaged/torso.vmt
materials/models/player/slow/predator_decamouflaged/torso.vtf
materials/models/player/slow/predator_decamouflaged/torso_norm.vtf 

Once we have our directories we want to make them downloadable. Simply put the command downloadable in front of each line, like so:

downloadable materials/models/player/slow/predatorcamouflaged/devices.vmt
downloadable materials/models/player/slow/predatorcamouflaged/limbs.vmt
downloadable materials/models/player/slow/predatorcamouflaged/torso.vmt
downloadable materials/models/player/slow/predatordecamouflaged/devices.vmt
downloadable materials/models/player/slow/predatordecamouflaged/devices.vtf
downloadable materials/models/player/slow/predatordecamouflaged/devicesnorm.vtf
downloadable materials/models/player/slow/predatordecamouflaged/limbs.vmt
downloadable materials/models/player/slow/predatordecamouflaged/limbs.vtf
downloadable materials/models/player/slow/predatordecamouflaged/limbsnorm.vtf
downloadable materials/models/player/slow/predatordecamouflaged/torso.vmt
downloadable materials/models/player/slow/predatordecamouflaged/torso.vtf
downloadable materials/models/player/slow/predatordecamouflaged/torso_norm.vtf
We always want to put the download commands in block load so we will put it in the script.

Copy the following into a notepad file:

block load
{
    // The download paths for each file.
    downloadable materials/models/player/slow/predatorcamouflaged/devices.vmt
    downloadable materials/models/player/slow/predatorcamouflaged/limbs.vmt
    downloadable materials/models/player/slow/predatorcamouflaged/torso.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/devices.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/devices.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/devicesnorm.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/limbs.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/limbs.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/limbsnorm.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/torso.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/torso.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/torsonorm.vtf
}
Basically what we did was tell the server to load the downloadable files on block load. The next step is to add the event to download. The one MOSTLY used is event esmapstart So we will add it into the script:
event esmapstart
{
    // The download paths for each file.
    downloadable materials/models/player/slow/predatorcamouflaged/devices.vmt
    downloadable materials/models/player/slow/predatorcamouflaged/limbs.vmt
    downloadable materials/models/player/slow/predatorcamouflaged/torso.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/devices.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/devices.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/devicesnorm.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/limbs.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/limbs.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/limbsnorm.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/torso.vmt
    downloadable materials/models/player/slow/predatordecamouflaged/torso.vtf
    downloadable materials/models/player/slow/predatordecamouflaged/torsonorm.vtf
}
This will tell us when the user is to download it. Doing this will ensure all players will download the files when they join the server after a map change.

That is the basics of adding downloads. The next thing is to use variables to control IF the player will download certain files. The following example depict whether the player will download both the models and the materials, or just the models:

block load
{
    esxsetinfo downloadmaterials 0 // set this to 1 if you want players to download the materials
    esxsetinfo downloadmodels 0 // set this to 1 if you want players to download the models

// The download paths for each file.
if (server_var(download_models) == 1) do
{
    downloadable materials/models/player/slow/predator_camouflaged/devices.vmt
    downloadable materials/models/player/slow/predator_camouflaged/limbs.vmt
    downloadable materials/models/player/slow/predator_camouflaged/torso.vmt
    downloadable materials/models/player/slow/predator_decamouflaged/devices.vmt
    downloadable materials/models/player/slow/predator_decamouflaged/devices.vtf
    downloadable materials/models/player/slow/predator_decamouflaged/devices_norm.vtf
    downloadable materials/models/player/slow/predator_decamouflaged/limbs.vmt
    downloadable materials/models/player/slow/predator_decamouflaged/limbs.vtf
    downloadable materials/models/player/slow/predator_decamouflaged/limbs_norm.vtf
    downloadable materials/models/player/slow/predator_decamouflaged/torso.vmt
    downloadable materials/models/player/slow/predator_decamouflaged/torso.vtf
    downloadable materials/models/player/slow/predator_decamouflaged/torso_norm.vtf
}
if (server_var(download_materials) == 1) do
{
    models/player/slow/predator_camouflaged/predator_camouflaged.dx80.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged.dx90.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged.mdl
    models/player/slow/predator_camouflaged/predator_camouflaged.phy
    models/player/slow/predator_camouflaged/predator_camouflaged.sw.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged.vvd
    models/player/slow/predator_camouflaged/predator_camouflaged_head.dx80.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged_head.dx90.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged_head.mdl
    models/player/slow/predator_camouflaged/predator_camouflaged_head.phy
    models/player/slow/predator_camouflaged/predator_camouflaged_head.sw.vtx
    models/player/slow/predator_camouflaged/predator_camouflaged_head.vvd
}

}

event esmapstart { if (servervar(downloadmodels) == 1) do { downloadable materials/models/player/slow/predatorcamouflaged/devices.vmt downloadable materials/models/player/slow/predatorcamouflaged/limbs.vmt downloadable materials/models/player/slow/predatorcamouflaged/torso.vmt downloadable materials/models/player/slow/predatordecamouflaged/devices.vmt downloadable materials/models/player/slow/predatordecamouflaged/devices.vtf downloadable materials/models/player/slow/predatordecamouflaged/devicesnorm.vtf downloadable materials/models/player/slow/predatordecamouflaged/limbs.vmt downloadable materials/models/player/slow/predatordecamouflaged/limbs.vtf downloadable materials/models/player/slow/predatordecamouflaged/limbsnorm.vtf downloadable materials/models/player/slow/predatordecamouflaged/torso.vmt downloadable materials/models/player/slow/predatordecamouflaged/torso.vtf downloadable materials/models/player/slow/predatordecamouflaged/torsonorm.vtf } if (servervar(downloadmaterials) == 1) do { models/player/slow/predatorcamouflaged/predatorcamouflaged.dx80.vtx models/player/slow/predatorcamouflaged/predatorcamouflaged.dx90.vtx models/player/slow/predatorcamouflaged/predatorcamouflaged.mdl models/player/slow/predatorcamouflaged/predatorcamouflaged.phy models/player/slow/predatorcamouflaged/predatorcamouflaged.sw.vtx models/player/slow/predatorcamouflaged/predatorcamouflaged.vvd models/player/slow/predatorcamouflaged/predatorcamouflagedhead.dx80.vtx models/player/slow/predatorcamouflaged/predatorcamouflagedhead.dx90.vtx models/player/slow/predatorcamouflaged/predatorcamouflagedhead.mdl models/player/slow/predatorcamouflaged/predatorcamouflagedhead.phy models/player/slow/predatorcamouflaged/predatorcamouflagedhead.sw.vtx models/player/slow/predatorcamouflaged/predatorcamouflaged_head.vvd } }

by adding the variables the server, it will check if the variables download_materials will allow the client to download the materials. If the variable it set to 0, players will not to be able download the files.

Anyway I hope this helped, if you have any questions just post below and I will reply asap.

Happy scripting! :)

Oh noes! You're not a Member!

Want access to cool stuff? As a member you can:

  • Post. Give the submitter your thoughts on this Tutorial.
  • Say Thanks. Show your appreciation by sending the submitter points.
  • Stamp Posts. Let other posters know what you think of their posts.
  • Rate. Give this Tutorial a rating out of 10.
  • Flag. Alert moderators and warn members of a problem with this Tutorial.
  • Vote. Vote the submitter for the Monthly Awards.
  • Subscribe. Get notified when this submitter submits again.

Interested? Register or Login

Comments

None found

Credits

Submitter
im_the_new_guy's Levels
  • P2: Drudge
    Points: 2,025
  • C1: Member
  • A5: Veteran
    Account Age: 4 years
im_the_new_guy (Creator/Co-creator)
Key Authors
Im the new guy
Creator

Rating

?/10
Not yet rated.

Additional Info

Genre
Coding/Scripting
Difficulty Level
Intermediate

Stats

Post Count
0
ViewCount
745
Date Added
3 years ago
Date Modified
3 years ago

Share

Embed Code
Code to use:

More embeddable images

Bookmark and Share