Left 4 Dead 2/Scripting/Script Functions/GetInvTable
< Left 4 Dead 2 | Scripting | Script Functions
Jump to navigation
Jump to search

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


January 2024
Function Description
void GetInvTable(CTerrorPLayer player,table invTable)
Fills invTable with the specified player's inventory. This function works on survivors and special infected.
Parameters
Type | Name | Description |
---|---|---|
CTerrorPlayer | player | Player who's inventory to get. |
table | invTable | Table for writing the inventory in. |
Example
// Prints a list of weapons each player is carrying
function PrintWeapons()
{
local player = null
// Iterate through every player
while(player = Entities.FindByClassname(player, "player"))
{
printl("Player: " + player.GetPlayerName())
// Add an empty table to store the inventory in
local invTable = {}
// Call the function to fill the table
GetInvTable(player, invTable)
// Check if the player has a primary weapon
if("slot0" in invTable)
{
printl("Primary weapon equipped: " + invTable.slot0)
}
else
{
printl("Primary weapon not equipped!")
}
// Print all equipped weapons
foreach(slot, weapon in invTable)
{
printl("\t" + slot + "= " + weapon.GetClassname())
}
}
}
PrintWeapons()
Output Parameters
Keys written to invTable
by the function.

in
keyword before using it.Type | Key | Description |
---|---|---|
handle | slot0 | Primary weapon |
handle | slot1 | Secondary weapon |
handle | slot2 | Throwable |
handle | slot3 | Medkit/Defib |
handle | slot4 | Pills/Adrenaline |
handle | slot5 | Carried physics object (L4D style, e.g. Gas can or the Gnome) |
handle | Held | Carried physics object (legacy style, from CanPickupObject() or PickupObject() ) |