Left 4 Dead 2/Scripting/Script Functions/GetInvTable: Difference between revisions
< Left 4 Dead 2 | Scripting | Script Functions
Jump to navigation
Jump to search
m (THE OWL moved page List of L4D2 Script Functions/GetInvTable to Left 4 Dead 2/Script Functions/GetInvTable) |
Thunder4ik (talk | contribs) m (clean up, added deadend tag) |
||
Line 1: | Line 1: | ||
{{Dead end|date=January 2024}} | |||
== Function Description == | == Function Description == | ||
Line 5: | Line 6: | ||
Fills ''invTable'' with the specified player's inventory. This function works on survivors and special infected. | Fills ''invTable'' with the specified player's inventory. This function works on survivors and special infected. | ||
== Parameters == | == Parameters == | ||
Line 23: | Line 22: | ||
|} | |} | ||
== Example == | |||
== Example == | |||
<source lang="cpp"> | <source lang="cpp"> | ||
Line 65: | Line 61: | ||
PrintWeapons() | PrintWeapons() | ||
</source> | </source> | ||
== Output Parameters == | == Output Parameters == | ||
Line 105: | Line 100: | ||
| Carried physics object (legacy style, from CanPickupObject() or PickupObject() ) | | Carried physics object (legacy style, from CanPickupObject() or PickupObject() ) | ||
|} | |} | ||
[[Category:Left 4 Dead 2]] | [[Category:Left 4 Dead 2]] | ||
[[Category:Scripting]] | [[Category:Scripting]] |
Revision as of 10:05, 21 January 2024

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() ) |