VIP

New GameMaps in development!

x

We are working hard to bring you the best experience possible with our upcoming relaunch!

You can help fund the relaunch by
Upgrading to VIP or Donating.

  • VIP Goal Progress: 100% Goal Reached!
  • Top Donator: Anonymous ($1,000)
Left 4 Dead 2
Left 4 Dead 2 is a single-player and multiplayer co-operative survival horror FPS game.
VSLib Developer Guide - Utilities
5,023
Utilities
Here are a couple of utilities that you can use.

Click here for a complete list.
String Functions
- Utils.StringReplace( string, find, replace ) - Allows you to find and replace portions of a string.

- Utils.CombineArray( array, delimiter = " " ) - Combines all the elements of an array into one string delimited by spaces.

- Utils.BuildProgressBar(width, count, goal, fill = "|", empty = ".") - Builds a textual progress bar.
Print Functions
-printf( string, ... ) - C style printf function with up to 12 arguments; prints to console

-Utils.SayToAll( string, ... ) - C style printf function that prints to the chatbox

-Utils.SayToAllDel( string, ... ) - C style printf function that prints to the chatbox with a 100 ms delay.

-Utils.SayToTeam(player, string, ...) - C style printf function that prints something to the specified src entity's (VSLib.Player) team

-Utils.SayToTeamDel(player, string, ...) - C style printf function that prints something to the specified src entity's (VSLib.Player) team with 100 ms delay
Spawn Functions
-Utils.CreateEntity( classname, spawnPos = Vector(0,0,0), angles = Vector(0,0,0), otherKeyValues = { } ) - Creates a new entity with the specified keyvalues and returns the VSLib.Entity to you.

-Utils.SpawnL4D1Survivor( survivor = BILL, spawnPos = Vector(0,0,0), angles = Vector(0,0,0) ) - Spawns a L4D1 survivor at the specified location with the specified angles: BILL, ZOEY, FRANCIS, and LOUIS

-Utils.SpawnZombie(pos, zombieType = "default", attackOnSpawn = true) - Spawns a zombie at the specified location with info_zombie_spawn.

-Utils.SpawnZombieNearPlayer( player, zombieNum, maxDist = 128, minDist = 32 ) - Spawns the requested zombie near a player and also checks to make sure that the spawn point is not visible to any survivor. Attempts to locate a position 20 times. If it can't find a suitable spawn location, it'll return false. Keep in mind that the closer the min and max distances are to each other, the lesser the chance that a suitable spawn will be found. For a good spawn chance, keep the min and max dist far apart. If by chance the survivors are looking everywhere at once, the infected prob won't spawn!
Math Functions
-Utils.CalculateDistance(vec1, vec2) - Calculates the distance between two vectors.

-Utils.VectorDotProduct(a, b) - Calculates the dot product of two vectors.

-Utils.VectorCrossProduct(a, b) - Calculates the cross product of two vectors.

-Utils.VectorFromQAngle(angles, radius = 1.0) - Converts QAngles into vectors, with an optional vector length.
Misc Functions
-Utils.SearchMainTables ( idx ) - Searches for an index at the root, round vars, and user vars tables.

-Utils.ForcePanicEvent( ) - Forces a panic event.
I found this article helpful
I did not find this article helpful
What people are saying...
You must be logged in to post a comment.
There are no comments yet for this guide.