Pointshop: Change viewmodel (hands)?

How do you change the viewmodel when making player models for Pointshop (by _undefined)?

I’ve tried calling ply:SetupHands() right after setting the player model (as suggested in this thread), but it doesn’t work.

I’ve also tried:


function ITEM:PlayerSpawn(ply, modifications)
     ply:SetModel(self.Model)
     ply:SetupHands()
end

I also tried some things from the gmod lua wiki, but with my lack of lua skills I recieved errors I couldn’t fix, and ended up removing the viewmodel completely and wasn’t able to switch weapons anymore.

Has anyone found a way to fix the viewmodel for pointshop playermodels?

http://wiki.garrysmod.com/page/player_manager/AddValidHandshttp://wiki.garrysmod.com/page/player_manager/TranslatePlayerModel
http://wiki.garrysmod.com/page/player_manager/TranslatePlayerHands

Not very helpful.

Like I said in the OP, I tried already by following the gmod wiki, but I’m messing it up somewhere along the way because I’m not very good with lua.

Try this


function ITEM:OnEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
	end
	timer.Simple(1, function() ply:SetModel(self.Model) ply:SetupHands() end)
end

function ITEM:OnHolster(ply)
	if ply._OldModel then
		ply:SetModel(ply._OldModel)
		ply:SetupHands()
	end
end

function ITEM:PlayerSetModel(ply)
	ply:SetModel(self.Model)
 	ply:SetupHands()
end

Thank you for the suggestion, but that’s what I originally tried, which didn’t work.

Here’s what I have so far:


ITEM.Name = 'Male 1'
ITEM.Price = 200
ITEM.Model = 'models/player/Group01/Male_01.mdl'

function ITEM:OnEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
	end
	
	timer.Simple(1, function() 
		ply:SetModel(self.Model)
		ply:SetupHands()
	end)
end

function ITEM:OnHolster(ply)
	if ply._OldModel then
		ply:SetModel(ply._OldModel)
		ply:SetupHands()
	end
end

function ITEM:PlayerSetModel(ply)
	ply:SetModel(self.Model)
	ply:SetupHands()
end

I don’t know exactly how the pointshop item hook system works, but this is the code you would use, where self_model represents the model.

[lua]
function GM:PlayerSetHandsModel( ply, ent )

local simplemodel = player_manager.TranslateToPlayerModelName( self_model )
local info = player_manager.TranslatePlayerHands( simplemodel )
if ( info ) then
	ent:SetModel( info.model )
	ent:SetSkin( info.skin )
	ent:SetBodyGroups( info.body )
end

end
[/lua]

I tried that as well but getting lua errors. I’m probably not setting up the arguments correctly.



ITEM.Name = 'TEST'
ITEM.Price = 200
ITEM.Model = 'models/player/Group01/Male_01.mdl'

function ITEM:OnEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
	end
	
	timer.Simple(1, function() 
		ply:SetModel(self.Model)
		ITEM:PlayerSetHandsModel(ply, ent)
	end)
end

function ITEM:OnHolster(ply)
	if ply._OldModel then
		ply:SetModel(ply._OldModel)
		ITEM:PlayerSetHandsModel(ply, ent)
	end
end

function ITEM:PlayerSetModel(ply)
	ply:SetModel(self.Model)
	ITEM:PlayerSetHandsModel(ply, ent)
end

function ITEM:Modify(modifications)
	PS:ShowColorChooser(self, modifications)
end

function ITEM:OnModify(ply, modifications)
	self:OnEquip(ply, modifications)
end


function ITEM:PlayerSetHandsModel( ply, ent )

	local simplemodel = player_manager.TranslateToPlayerModelName( self.Model )
	local info = player_manager.TranslatePlayerHands( simplemodel )
	if ( info ) then
		ent:SetModel( info.model )
		ent:SetSkin( info.skin )
		ent:SetBodyGroups( info.body )
	end

end

I’m guessing “ent” comes out as a nil value (attempting to call method SetModel (A nil value) ).

I’ve often found the gmod wiki to lack working examples for lua noobs. It would be helpful if that page had an example how to properly call the function and specify the arguments.

I also tried calling the function like this earlier, and recieved lua errors:


ITEM:PlayerSetHandsModel(ply, ply:GetViewModel( 0 ))

Pointshop wiki about hooking functions from items