Player.GetActiveWeapon

From GMod Wiki

Jump to: navigation, search
Function
Syntax Player:GetActiveWeapon( )
Description:
Returns what weapon the player is currently holding.
Returns: Weapon
In Object: Player
Realm: NewerShared.png
BBCode Link: [b][url=http://wiki.garrysmod.com/?title=Player.GetActiveWeapon]Player.GetActiveWeapon [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b]


Examples

DescriptionThe following example would show a weapon being found to print ammo to the screen.
Used onNewerShared.png
Code
 
draw.SimpleText(LocalPlayer():GetAmmoCount(LocalPlayer():GetActiveWeapon():GetPrimaryAmmoType()) .. "", "ScoreBoardText", ScrW() * .5, ScrH() * .5, Color(0, 0, 0, 255), 0, 0)
 
OutputThis shows that the ammo would display in dark text at the middle of the screen.
Personal tools
Namespaces
Variants
Actions
Navigation
Lua Scripting
Functions
Hooks
Toolbox