Player/GetWeapons

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
m (Bug)
Line 2: Line 2:
 
|Description=Returns a table of the player's weapons.
 
|Description=Returns a table of the player's weapons.
  
{{Bug|Issue=3052|The table returned is not continuous so the # operator, {{GlobalFunction|ipairs}}, and a numeric-for loop shouldn't be used with it. Use {{LibraryFunction|table|Count}} to get the correct count, instead.}}
+
{{Bug|Issue=3052|Fixed=|The table returned is not continuous so the # operator, {{GlobalFunction|ipairs}}, and a numeric-for loop shouldn't be used with it. Use {{LibraryFunction|table|Count}} to get the correct count, instead.}}
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes

Revision as of 14:22, 12 August 2019

 Player:GetWeapons( )

Contents

Description

Returns a table of the player's weapons.

BUG

The table returned is not continuous so the # operator, ipairs, and a numeric-for loop shouldn't be used with it. Use table.Count to get the correct count, instead.

Issue Tracker: #3052

This bug will be fixed in the next update.

Returns

table

All the weapons the player currently has.

Examples

Example

Prints how many weapons the player has.

print(table.Count(Player(1):GetWeapons()))

Output:

The number of weapons the player has (e.g. 5).
Personal tools
Navigation