Multiple skins on one model with $texturegroup skinfamilies

Hey,
I’m trying to create a new weapon based on a model that already has 3 different skins (which are all working fine and used for 3 different weapons). I created a 4th skin that I want to use with the new weapon.

This is how the skinfamilies part of the .qc file looks:


$texturegroup skinfamilies
{
	{ "skin1.vmt" }
	{ "skin2.vmt" }
	{ "skin3.vmt" }
	{ "skin4.vmt" }
}

All I have modified within this fully working .qc file is that I added the skin4.vmt, which I correctly created + used VTFEdit+Adobe Illustrator to create proper skin4.vtf.

I also have a SWEP functions like this:



function SWEP:Initialize()
	self:SetWeaponHoldType( self.HoldType )
	if ( self.Skin ) then self:SetSkin( self.Skin ) end
end




function SWEP:PreDrawViewModel( vm )
	if ( self.Skin && IsValid( vm ) ) then vm:SetSkin( self.Skin ) end
end


And in my new weapon.lua file I have set this to get my weapon to use the skin4.vmt:


SWEP.Skin = 3

However the new weapon still displays the “0” skin in-game. I used the Entity.GetSkin() to find out that my weapon’s skin is set to “3”, but all I see in-game is the skin “0”.
I also used Entity.SkinCount() and it returned the number “4” representing that the model has 4 skins, which is exactly what I want.

As the first 3 working weapons’ textures are defined by this single number in their lua files, I made an assumption that if I add a new texture to the skinfamilies within the .qc file, that one will be assigned the next skin-value (3), as skin1 is the number 0, skin2 is number 1, and skin3 is number 2.

So what I am asking is, do I need to define it anywhere else other than the .qc file, that my model has 4 skins and not the default 3? Because the value “SWEP.Skin = 3” displays skin1.vmt for me instead of the skin4.vmt that I want it to display. (My weapon’s SWEP.Base uses the skin 0, but this shouldn’t matter since my weapon should overwrite it by using the skin 3)

I hope I am making sense with my post, it is really difficult to explain this any better. If there is any more information that I should supply to get help, I will gladly do so.
Thanks in advance to anyone who’s willing to help!

Have you tried setting the skin of the owner’s viewmodel on deploy and resetting it on weapon remove/drop/etc?

All my SWEP:Deploy() does is it sends the clientside animation and returns true, so that one has nothing to do with setting the skin. But the skin should be set correctly, because skin1.vmt, skin2.vmt and skin3.vmt are all for seperate weapons and all of those 3 weapons work perfectly fine with the same code.

And also because as I said before, I have checked with print(self:GetSkin()) that the skin was number 3 while I had the weapon drawn.

So my problem is, the game does not recognize what the skin number 3 is. This is why I’m asking if I need to define the model’s skin amount somewhere else.

Reread my post. Set the skin of the OWNER’S VIEWMODEL. Not just the weapon entity.

Yup. This is what I have.



function SWEP:PreDrawViewModel( vm )
	if ( self.Skin && IsValid( vm ) ) then vm:SetSkin( self.Skin ) end
end


The format for $texturegroup is as such:



$texturegroup skinfamilies
{
	{ "original material on the model" }
	{ "skin1" }
	{ "skin2." }
	{ "skin3" }
}

So, from your code, you only have additional 3 skins. Futhermore, you don’t need .vmt in the .qc.

Yes, but I also use the original material as it’s own weapon, so that’s 4 skins total. The 3 first ones were there by default and I only added the last one.

I removed the .vmt extensions sure, but that doesn’t remove the problem.

EDIT: Problem solved, somehow my server was still using workshop files for the gammode’s default skins so I had to remove the workshop ID from the file.