I want to have a custom weapon switching thing instead of the normal one at the top of the screen because I wont be using conventional weapon entities. SO the two things i would like to know is how to disable the current one and also how to get when the user scrolls the mouse wheel.
UPDATE:
I think i can use if(input.IsMouseDown( MOUSE_WHEEL_DOWN )) in the think event to test whether or not the user is trying to switch weapons. Is this correct or should I use something else?
Well ignore the last part because I figured out a better way to work the custom weapon switcher. The only thing I need now is how to disable the current one.
[QUOTE=Salmonman;32174762]Well ignore the last part because I figured out a better way to work the custom weapon switcher. The only thing I need now is how to disable the current one.[/QUOTE]
[url]http://wiki.garrysmod.com/?title=Player.StripWeapon[/url]
I still want the player to be able to use the physgun, camera, and toolgun though. Can i still have them do that and not have the standard weapon list thing?
Edit:
I took off the HEV suit from the player which disables those pesky HUD elements, so that problem is solved. However, when I used ply:SetActiveWeapon() in my custom code, the weapon model i see doesnt update until i left click once. Is there any way I can fix THAT now?
To hide the current weapon selection: Block the CHudWeaponSelection via HUDShouldDraw
To handle your own, you will need to hook PlayerBindPress
You will need to handle the slot binds ( 1, 2, 3, 4, 5, 6, 7, 8, 9, 0 ). These are by default bound to the number keys.
You will need to handle invnext and invprev, which is what the scroll wheel does by default.
To actually select the weapon, track the class name of the selected weapon, and simply run this command:
use weaponclass
Where weaponclass would be something like weapon_pistol or weapon_crowbar, for example.
It's a bit messy, but that's the method that works for me.
Thanks for the info on CHudWeaponSelection, when i looked up the other ones I didnt see it so I must have stroked off there for a second. Also, what exactly is use weaponclass? Is it a console command? Would i say [code]ply:ConCommand("use"+tostring(weapon))[/code]
EDIT:
:D You sir do know your stuff. Everything is working great. Youve given me more info on the subject than anyone else. Also, i used GetClass() instead of tostring()
Sorry, you need to Log In to post a reply to this thread.