Custom SWEP with Fists viewmodel?

So I have a “hands” swep for an RP gamemode, and I want to replace the view model with the Fists viewmodel and animations. The following does not work:
SWEP.ViewModel = “models/weapons/c_arms_citizen.mdl”;

How can I make this possible?

Also, I want it so that until the player primary fires, the player stands still instead of being in a fighting stance.
The default FISTS swep also doesn’t have a viewmodel, does any1 know what is the cause of this?

Try This


function SWEP:PreDrawViewModel( vm, wep, ply )

	vm:SetMaterial( "engine/occlusionproxy" )

end

Didn’t work :frowning:

Have a look at default hands swep in gmod.

Even the default SWEP doesn’t have a viewmodel, I guess it’s some other problem. Do you have any idea?

This might help: http://wiki.garrysmod.com/page/Using_Viewmodel_Hands

“If a player model doesn’t have a corresponding hands entry, it will default to the civilian hands.”
So, I’m guessing I don’t need to use “AddValidHands”

I tried:



local pMeta = FindMetaTable("Player")
function pMeta:GetHandsModel()
	return { model = "models/weapons/c_arms_citizen.mdl", skin = 1, body = "0100000" }
end


But no avail.

I though you were making a SWEP, where did this come from?

[editline]15th June 2013[/editline]

Try using the same view model as you have now but also set the world model to " " and add SWEP:UseHands = true as well as the code that AirBlack suggested.

I literally just made a duplicate swep using the Fists code and still no view model.

Bump…still have the problem :frowning:

Did you try my suggestion in the edit to my last post?

@ShadowRanger, Yes I did, it seems that hands just don’t work in my custom gamemode. They work in single player.

To your GM:PlayerSpawn



local oldhands = ply:GetHands()
	if ( IsValid( oldhands ) ) then oldhands:Remove() end

	local hands = ents.Create( "gmod_hands" )
	if ( IsValid( hands ) ) then
		ply:SetHands( hands )
		hands:SetOwner( ply )

		-- Which hands should we use?
		local cl_playermodel = ply:GetInfo( "cl_playermodel" )
		local info = player_manager.TranslatePlayerHands( cl_playermodel )
		if ( info ) then
			hands:SetModel( info.model )
			hands:SetSkin( info.skin )
			hands:SetBodyGroups( info.body )
		end

		-- Attach them to the viewmodel
		local vm = ply:GetViewModel( 0 )
		hands:AttachToViewmodel( vm )

		vm:DeleteOnRemove( hands )
		ply:DeleteOnRemove( hands )

		hands:Spawn()
	end

To your GM:PostDrawViewModel, cl_init.lua



function GM:PostDrawViewModel( vm, ply, weapon )
   if weapon.UseHands or (not weapon:IsScripted()) then
      local hands = LocalPlayer():GetHands()
      if IsValid(hands) then hands:DrawModel() end
   end
end

Why don’t you just learn how other gamemodes did it?

Thanks a lot, I really should have just searched through other gamemodes. Next time, I’ll do that before making a help thread. :slight_smile: