VSLib
Simple, powerful VScript Library for L4D2
 All Classes Namespaces Files Functions Pages
VSLib.Player Class Reference

Provides many helpful player functions. More...

Inheritance diagram for VSLib.Player:
VSLib.Entity

Private Member Functions

bool IsPlayerEntityValid ()
 
string GetCharacterName ()
 
string GetSteamID ()
 
string GetUniqueID ()
 
string GetName ()
 
string GetIPAddress ()
 
bool IsAlive ()
 
bool IsDead ()
 
bool IsDying ()
 
bool IsIncapacitated ()
 
bool IsHangingFromLedge ()
 
bool IsGhost ()
 
bool IsOnFire ()
 
Entity GetActiveWeapon ()
 
bool IsInEndingSafeRoom ()
 
Vector GetSpawnLocation ()
 
bool IsNearStartingArea ()
 
Player GetLastAttacker ()
 
bool HasAward (int award)
 
Player GetLastKilledBy ()
 
Player GetLastDefibbedBy ()
 
Entity GetLastShovedBy ()
 
Entity GetLastUsed ()
 
int GetTeam ()
 
string GetLastAbilityUsed ()
 
Player GetCurrentAttacker ()
 
bool IsSurvivorTrapped ()
 
int GetPlayerType ()
 
void Incapacitate ()
 
void Kill ()
 
bool CanSeeLocation (Vector targetPos, int tolerance=50)
 
bool CanSeeOtherEntity (Entity otherEntity, int tolerance=50)
 
bool CanTraceToLocation (Vector finishPos, int traceMask)
 
void ClientCommand (string str)
 
void SetFlashlight (bool turnFlashOn)
 
void SetHealthBuffer (int value)
 
void DropWeaponSlot (slot)
 
void DropAllWeapons ()
 
int GetHealthBuffer ()
 
object[] GetHeldItems ()
 
Vector GetLastDeathLocation ()
 
void SetReviveCount (int count)
 
int GetReviveCount ()
 
bool Revive ()
 
bool Defib ()
 
Player GetLastVomitedBy ()
 
bool WasEverVomited ()
 
void Stagger ()
 
void StaggerAwayFromEntity (Entity otherEnt)
 
void StaggerAwayFromLocation (Vector loc)
 
void GiveUpgrade (string upgrade)
 
void RemoveUpgrade (string upgrade)
 
bool IsFrustrated ()
 
void GiveAdrenaline (double time)
 
int GetUserId ()
 
int GetSurvivorSlot ()
 
bool Extinguish ()
 
void GiveAmmo (int amount)
 
Vector GetNearbyLocation (double radius)
 
double GetFlowDistance ()
 
double GetFlowPercent ()
 
void PlaySound (string file)
 
string StopSound (string file)
 
void DisablePickups ()
 
void AllowPickups (long int BTN_PICKUP, long int BTN_THROW)
 
void DropPickup ()
 
void NativePickupObject (Entity otherEnt)
 
void Give (string str)
 
void Remove (string weaponName)
 
void BeginValvePickupObjects (string pickupSound="Defibrillator.Use", string throwSound="Adrenaline.NeedleOpen")
 
void EndValvePickupObjects ()
 
bool ValvePickupThrowPower (double power)
 
bool ValvePickupPickupRange (double range)
 
void SetThrowDamage (double dmg)
 
void SetHoldDamage (double dmg)
 
void SetDamageEnabled (bool isEnabled)
 
int GetInventory (string itemName)
 
void SetInventory (string itemName, int quantity)
 
object[] GetInventoryTable ()
 

Detailed Description

Provides many helpful player functions.

The Player class works with ::VSLib.EasyLogic.Notifications and builds on the Entity class.

Member Function Documentation

void VSLib.Player.AllowPickups ( long int  BTN_PICKUP,
long int  BTN_THROW 
)
private

Enables Amnesia/HL2 style object pickups. Currently does not work.

void VSLib.Player.BeginValvePickupObjects ( string  pickupSound = "Defibrillator.Use",
string  throwSound = "Adrenaline.NeedleOpen" 
)
private

Enables Valve-style object pickups with the USE key (E key). Similar to the Gravity Gun effect.

bool VSLib.Player.CanSeeLocation ( Vector  targetPos,
int  tolerance = 50 
)
private

Returns true if this player can see the inputted location in their vision.

Parameters
targetPosThe vector location that you want to check if the player can see.
toleranceThe tolerence of the result. 75 is the default Source field of view.
bool VSLib.Player.CanSeeOtherEntity ( Entity  otherEntity,
int  tolerance = 50 
)
private

Returns true if this player can see the inputted entity.

bool VSLib.Player.CanTraceToLocation ( Vector  finishPos,
int  traceMask 
)
private

Returns true if this player can trace a line from the eyes to the specified location. See this page https://developer.valvesoftware.com/wiki/MASK_Types for trace mask types. Other functions in VSLib like Utils::SpawnZombieNearPlayer also use this function, so see those for examples.

void VSLib.Player.ClientCommand ( string  str)
private

Sends a client command to the player entity.

bool VSLib.Player.Defib ( )
private

Defibs a dead player (also checks if player is dead first). Returns true if the player was defibbed.

void VSLib.Player.DisablePickups ( )
private

Stops Amnesia/HL2 style object pickups. Currently does not work.

void VSLib.Player.DropAllWeapons ( )
private

Drops all held weapons

void VSLib.Player.DropPickup ( )
private

Drops the held HL2/Amnesia physics-based object or the valve-style object

void VSLib.Player.DropWeaponSlot ( slot  )
private

Drops a weapon from a slot.

You can use global constants SLOT_PRIMARY, SLOT_SECONDARY, SLOT_THROW, SLOT_MEDKIT (also works for defibs), SLOT_PILLS (also works for adrenaline etc)

void VSLib.Player.EndValvePickupObjects ( )
private

Disables Valve-style object pickups.

See also
BeginValvePickupObjects
bool VSLib.Player.Extinguish ( )
private

Extinguish a burning player (also checks if player is on fire first). Returns true if the player was extinguished.

Entity VSLib.Player.GetActiveWeapon ( )
private

Returns the VSLib::Entity of the player's active weapon

string VSLib.Player.GetCharacterName ( )
private

Gets the character name (not steam name). E.g. "Nick" or "Rochelle"

Player VSLib.Player.GetCurrentAttacker ( )
private

Returns the Player entity of the current attacker, or null if there is no entity attacking this player. Note that this function will only return the current hunter, smoker, charger, or jockey attacker. Boomer, tank, and spitter cannot "continuously" trap the survivor and attack, so they will not be returned. If there is no SI attacking this player, then null is returned. This function is applicable for Survivors only.

double VSLib.Player.GetFlowDistance ( )
private

Gets flow distance.

double VSLib.Player.GetFlowPercent ( )
private

Gets flow percent.

int VSLib.Player.GetHealthBuffer ( )
private

Gets the player's health buffer.

object [] VSLib.Player.GetHeldItems ( )
private

Gets the player's valve inventory (molotov, weapons, pills, etc).

int VSLib.Player.GetInventory ( string  itemName)
private

Returns the quantity of the requested inventory item. Inventory items can be spawned with Utils::SpawnInventoryItem().

See also
GetInventoryTable()
object [] VSLib.Player.GetInventoryTable ( )
private

Returns the player's inventory table. You can use it like this:

    local inv = player.GetInventoryTable();
    inv["itemName"] <- 25; // change quantity to 25
string VSLib.Player.GetIPAddress ( )
private

Gets the player's IP address.

string VSLib.Player.GetLastAbilityUsed ( )
private

Returns the last ability that this player used. E.g. "ability_lunge" or "ability_tongue" or "ability_vomit" or "ability_charge" or "ability_spit" or "ability_ride" This function is applicable for SI only.

Player VSLib.Player.GetLastAttacker ( )
private

Returns the player's last attacker (the last person who hurt this player). Null is returned if the "attacker" is the world or some other invalid object.

Vector VSLib.Player.GetLastDeathLocation ( )
private

Gets the position where the player last died, or null if the player has not died yet

Player VSLib.Player.GetLastDefibbedBy ( )
private

Returns the entity or player that last defibbed this player. If this player has not been defibbed or hasn't been defibbed by a valid player entity, returns null.

Player VSLib.Player.GetLastKilledBy ( )
private

Returns the entity or player that last killed this player. If this player has not been killed yet or the killer is an invalid object, returns null.

Entity VSLib.Player.GetLastShovedBy ( )
private

Returns the entity or player that last shoved this player. If this player has not been shoved yet, returns null.

Entity VSLib.Player.GetLastUsed ( )
private

Returns the entity that this player last tried to "Use". If the player has not tried to use anything yet, returns null.

Player VSLib.Player.GetLastVomitedBy ( )
private

Gets the last player who vomited this player, or returns null if the player has not been vomited on yet OR has not been vomited on by a valid player

string VSLib.Player.GetName ( )
private

Gets the player's name.

Vector VSLib.Player.GetNearbyLocation ( double  radius)
private

Gets a valid path point within a radius.

int VSLib.Player.GetPlayerType ( )
private

Returns the type of player. E.g. Z_SPITTER, Z_TANK, Z_SURVIVOR, Z_HUNTER, Z_JOCKEY, Z_SMOKER, Z_BOOMER, Z_CHARGER, Z_COMMON, or UNKNOWN.

int VSLib.Player.GetReviveCount ( )
private

Gets the player's revive count, or null if the player does not have revive information yet

Vector VSLib.Player.GetSpawnLocation ( )
private

Gets the player's spawn location.

string VSLib.Player.GetSteamID ( )
private

Gets the player's Steam ID. If you are planning on getting the SteamID to store it with FileIO.SaveTable, use GetUniqueID() instead,

int VSLib.Player.GetSurvivorSlot ( )
private

Gets the survivor slot

int VSLib.Player.GetTeam ( )
private

Returns the team that this player is currently on, e.g. SURVIVORS or INFECTED.

string VSLib.Player.GetUniqueID ( )
private

Gets the player's Unqiue ID (clean, formatted Steam ID).

int VSLib.Player.GetUserId ( )
private

Gets the userid of the player.

void VSLib.Player.Give ( string  str)
private

The "give" concommand.

Parameters
strWhat to give the entity (for example, "health")
void VSLib.Player.GiveAdrenaline ( double  time)
private

Gives the entity an adrenaline effect

void VSLib.Player.GiveAmmo ( int  amount)
private

Gives ammo to the player.

void VSLib.Player.GiveUpgrade ( string  upgrade)
private

Gives the player an upgrade

bool VSLib.Player.HasAward ( int  award)
private

Returns true if the player has earned some kind of award this round. For example, award 67 is when a player protects another player. If you do HasAward(67), the function will return true if and only if the player has protected another player sometime that round. So, you ask, how do I find out which number is what? Good question! Trial and error. Use EasyLogic.Notifications.OnAwarded hook to find out what awards are given when you do something in-game. Then use the number you find out to do whatever it is that you need to do. You may be thinking that it sounds complicated, but it's easier with VSLib than if you were to do the same without it.

void VSLib.Player.Incapacitate ( )
private

Incaps the player

bool VSLib.Player.IsAlive ( )
private

Returns true if the player is alive.

bool VSLib.Player.IsDead ( )
private

Returns true if the player is dead.

bool VSLib.Player.IsDying ( )
private

Returns true if the player is dying.

bool VSLib.Player.IsFrustrated ( )
private

Returns true if the player is a tank and is frustrated

bool VSLib.Player.IsGhost ( )
private

Returns true if the entity is in ghost mode (i.e. infected ghost).

bool VSLib.Player.IsHangingFromLedge ( )
private

Returns true if the entity is hanging off a ledge.

bool VSLib.Player.IsIncapacitated ( )
private

Returns true if the entity is incapped.

bool VSLib.Player.IsInEndingSafeRoom ( )
private

Returns true if the player is currently in the ending saferoom.

bool VSLib.Player.IsNearStartingArea ( )
private

Returns true if the player is still around the starting area. Note that they can be outside the saferoom and still AROUND the starting area. This function will return true if they are near where they first spawned.

bool VSLib.Player.IsOnFire ( )
private

Returns true if the entity is on fire.

bool VSLib.Player.IsPlayerEntityValid ( )
private

Returns true if the player entity is valid or false otherwise.

bool VSLib.Player.IsSurvivorTrapped ( )
private

Returns true if the Survivor player is trapped by an SI attacker like smoker, hunter, charger, or jockey.

void VSLib.Player.Kill ( )
private

Kills the player.

void VSLib.Player.NativePickupObject ( Entity  otherEnt)
private

Picks up the given VSLib Entity object using native L4D2 function.

void VSLib.Player.PlaySound ( string  file)
private

Plays a sound file to the player.

void VSLib.Player.Remove ( string  weaponName)
private

Removes a player's weapon.

void VSLib.Player.RemoveUpgrade ( string  upgrade)
private

Removes the player's upgrade

bool VSLib.Player.Revive ( )
private

Revives a player (also checks if player is incapped first). Returns true if the player was revived.

void VSLib.Player.SetDamageEnabled ( bool  isEnabled)
private

Enables or disables hold/throw damage calculation.

See also
BeginValvePickupObjects
void VSLib.Player.SetFlashlight ( bool  turnFlashOn)
private

Changes the flashlight state.

void VSLib.Player.SetHealthBuffer ( int  value)
private

Sets the player's health buffer.

void VSLib.Player.SetHoldDamage ( double  dmg)
private

Sets the hold damage for Valve-style object pickups (default 5).

See also
BeginValvePickupObjects
void VSLib.Player.SetInventory ( string  itemName,
int  quantity 
)
private

Sets the quantity of the specified inventory item.

See also
GetInventoryTable()
void VSLib.Player.SetReviveCount ( int  count)
private

Sets the player's revive count. Setting the value high enough could also make them go black and white.

void VSLib.Player.SetThrowDamage ( double  dmg)
private

Sets the throw damage for Valve-style object pickups (default 30).

See also
BeginValvePickupObjects
void VSLib.Player.Stagger ( )
private

Staggers this entity

void VSLib.Player.StaggerAwayFromEntity ( Entity  otherEnt)
private

Staggers this entity away from another entity

void VSLib.Player.StaggerAwayFromLocation ( Vector  loc)
private

Staggers this entity away from another location

string VSLib.Player.StopSound ( string  file)
private

Stops a sound on the player.

bool VSLib.Player.ValvePickupPickupRange ( double  range)
private

Sets the pickup range for Valve-style object pickups (default 64).

See also
BeginValvePickupObjects
bool VSLib.Player.ValvePickupThrowPower ( double  power)
private

Sets the throwing force for Valve-style object pickups (default 100).

See also
BeginValvePickupObjects
bool VSLib.Player.WasEverVomited ( )
private

Returns true if this player was ever vomited this round


The documentation for this class was generated from the following file: