From Valve Developer Community
Jump to: navigation, search
Dead End - Icon.png
This article has no links to other VDC articles. Please help improve this article by adding links that are relevant to the context within the existing text.
January 2024

VSLib (VScript Library) is a simple, lightweight library for L4D2's VScript mutation system. It is a loose collection of classes and functions that work together to provide additional features. VSLib is designed to be re-usable and easily updatable. Taking advantage of the entire library requires the programmer to add only a single line of code! Add this line in the beginning of the script, outside any function:


Download VSLib on GitHub.


  • Synchronous timer system: Those who have coded plugins for SourceMod know about SM's powerful timer system. VSLib introduces the same kind of timer system: delayed function calls, repeatability, and argument support. The timer system allows the modder to fire a function (with any arguments) after a delay.
  • Entity class: Provides many new functions for entities, such as Ignite(), AttachParticle(), Hurt(), Kill(), GetTeam(), etc etc.
  • Player class: Builds on the Entity class to provide many more functions for survivor/infected entities: SetFlashlight(), GetSteamID(), GetIPAddress(), GetName(), etc.
  • EasyLogic system: As the name suggests, this table helps simplify the implementation of logic. Things such as ChatTriggers, save data, and game event notifications are managed by this table.
  • Utils table: Random but helpful utility functions.
  • HUD class: A collection of numerous HUD types.

Comparing normal VScripts and VSLib-enhanced scripts

See the difference between normal VScripts and VSLib below.

Normal VScripts
  function OnGameEvent_player_now_it ( params )
      if ( params["userid"] != null && params["userid"] != "" )
              local victim = GetPlayerFromUserID( params["userid"] );
              if ( victim != null && victim.IsValid() )
                      local name = GetCharacterDisplayName(victim);
                      Say( null, name + " was vomited on!", false );
Same VScript using VSLib
   function Notifications::OnPlayerVomited::NotifyEveryoneBro ( victim, boomer, params )
       Utils.SayToAll( "%s was vomited on!", victim.GetName() );

As you can see, VSLib-enhanced scripts are far simpler to code and understand.

Some mods using VSLib

The following are some mods that use VSLib. You can download these mods and view their source code for examples.

Stranded: Intense survival experience. http://steamcommunity.com/sharedfiles/filedetails/?id=157525096

Rayman1103's Admin System: Epic admin system mod. http://steamcommunity.com/sharedfiles/filedetails/?id=214630948

Shotgunefx's Path Recorder: A really nice helper utility to record camera and vehicle paths. http://steamcommunity.com/sharedfiles/filedetails/?id=180944985

Boomer Peril: Tank Rush with a twist. http://steamcommunity.com/sharedfiles/filedetails/?id=157524450

Vicious Infected: Inspired by the SM plugin, this plugin takes infected to new heights. http://steamcommunity.com/sharedfiles/filedetails/?id=157523582

Download VSLib

Download VSLib on GitHub.

External Links

Wikipedia - Letter.png
This article has not been added to any content categories. Please help out by adding categories.
January 2024