Using Viewmodel Hands
To make your SWEP use the viewmodel hands, add this code:
Note that your SWEP must also use a C model for its viewmodel:
If you want to use the Viewmodel Hands system in your gamemode, you must put some code into your gamemode.
Serverside: ( This MUST go into a GM:PlayerSpawn function, paste it to the end )
Serverside: ( Again, must be put into GM:PlayerSpawn after you set players class )
By default GM:PlayerSetHandsModel calls GetHandsModel of players current player class.
If you haven't overridden GM:PostDrawViewModel, this step is optional.
This code makes the hands draw. It must be clientside.
If you want a specific player class to use specific hands then add this function.
If you're adding a player model and want to add custom hands then use this code.
Where 'css_arctic' is the name you used when calling player_manager.AddValidModel — the two numbers are respectively the skin and bodygroup values.
If a player model doesn't have a corresponding hands entry, it will default to the civilian hands.
Here's an example c_model that shows how things need to be set up in your QC and SMD files. This is the source files of the medkit SWEP that is packed by default with Gmod.
Here are the source files for the c_arms_citizen model, if you need some reference for compiling arms:
Here's the citizen arms on a CAT animation rig.
If you need SMD files for these arms (making your own animation rigs, etc.), here they are.
The arms mesh should never be in the weapon model itself; that defeats the entire purpose of the system!
Remember to include c_arms_definebones.qci from the medkit example, as otherwise StudioMDL will optimise away the arm bones that you've included and then it won't work.