Ads keep us online. Without them, we wouldn't exist. We don't have paywalls or sell mods - we never will. But every month we have large bills and running ads is our only way to cover them. Please consider unblocking us. Thank you from GameBanana <3

Learning Eventscripts: Make stuf download using ES

A Tutorial for Counter-Strike: Source

Members see zero ads. Membership is 100% free

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/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
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/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
}
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 es_map_start So we will add it into the script:
event es_map_start
{
	// The download paths for each file.
	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
}
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
{
	es_xsetinfo download_materials 0 // set this to 1 if you want players to download the materials
	es_xsetinfo download_models 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 es_map_start
{
	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
	}
}
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! :)

Comments

Sign up to access this!

No comments yet

Embed

menu
Share banner
Image URL
HTML embed code
BB embed code
Markdown embed code

Credits

Key Authors
Im the new guy
Creator

Submitter

im_the_new_guy avatar
im_the_new_guy username pic Joined 11y ago
Offline
15,815 points Ranked 348th
24 medals 2 legendary 3 rare
  • Submitted 50 Maps Medal icon
  • 10 years a member Medal icon
  • 6 years a member Medal icon
  • Returned 1000 times Medal icon
  • Submitted 20 Maps Medal icon
  • Mapper of the Month, November 2013 Medal icon
im_the_new_guy avatar
im_the_new_guy

Creator
Sign up to access this!
Sign up to access this!
Sign up to access this!

Game

Sign up to access this!

Category

Details

Difficulty Level
Intermediate

Attributes

Share

  • Share on Reddit
  • Share on Twitter
  • Share on Facebook
  • favorite 0
  • remove_red_eye 2.4k
  • access_time 9y

More from Submitter

menu

More Scripting Tutorials