Using Viewmodel Hands
Scripted Weapons
To make your SWEP use the viewmodel hands, add this code:
Note that your SWEP must also use a C model for its viewmodel:
Custom Gamemodes
If you want to use the Viewmodel Hands system in your gamemode, you must put some code into your gamemode.
Without Player Classes
Serverside: ( This MUST go into a GM:PlayerSpawn function, paste it to the end )
Using Player Classes
Serverside: ( Again, must be put into GM:PlayerSpawn after you set players class )
By default GM:PlayerSetHandsModel calls GetHandsModel of players current player class.
Clientside code
If you haven't overridden GM:PostDrawViewModel, this step is optional.
This code makes the hands draw. It must be clientside.
Player Class
If you want a specific player class to use specific hands then add this function.
Player Models
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.
Model creators
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.