There's any way that I can get the Weapon() using the weapon class? Not using player:activeweapon(), player:getWeapon().
Something like:
weapon = getWeaponByName("weapon_smg")
Basically no.
A weapon entity must exist for you to be able to "get it", whether it is lying on the ground or is owned by a player.
you can use this [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindByClass]ents.FindByClass[/url]
but it returns a table
Adding on, if it does exist and a player is holding it, you should be able to get it from a player holding it with [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/GetWeapon]Player:GetWeapon[/url]
Each weapon has it's own entity class, so calling ents.FindByClass() or running ents.GetAll() checking if the ent is the weapon class name should do the trick.
Sorry, you need to Log In to post a reply to this thread.