Player/GetWeapons

From Garry's Mod
(Difference between revisions)
Jump to: navigation, search
(Added note about sequential)
m (Noted continuous table bug)
Line 1: Line 1:
 
{{Func
 
{{Func
 
|Description=Returns a table of the player's weapons.
 
|Description=Returns a table of the player's weapons.
 +
 +
The table returned is not continuous due to a [https://github.com/Facepunch/garrysmod-issues/issues/3052 bug], so you should not use the # operator on the table or loop with ipairs/numeric-for.
 
|Realm=Shared
 
|Realm=Shared
 
|IsClass=Yes
 
|IsClass=Yes
Line 7: Line 9:
 
|type=table
 
|type=table
 
|desc=All the weapons the player currently has.
 
|desc=All the weapons the player currently has.
This table is not guaranteed to be sequential.
 
 
}}
 
}}
 
{{Example
 
{{Example

Revision as of 01:47, 6 March 2018

 Player:GetWeapons( )

Contents

Description

Returns a table of the player's weapons.

The table returned is not continuous due to a bug, so you should not use the # operator on the table or loop with ipairs/numeric-for.

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