Pointshop Mask Issue

I’ve been attempting to make my own version of the Pointshop mask using the way the Pointshop’s text hat draws text, and so far I’ve had little success.
The code I’ve got so far can be seen below. What can I do to actually make it show, because there are no errors currently but the image won’t show.


ITEM.Name = 'Mask Test'
ITEM.Price = 20 
ITEM.Material = 'masks/ie.png'

function ITEM:PostPlayerDraw(ply, modifications, ply2)
	if not ply == ply2 then return end
	if not ply:Alive() then return end
	if ply.IsSpec and ply:IsSpec() then return end
	
	local ang = LocalPlayer():EyeAngles()
	local pos = ply:GetPos() + ang:Up()
	
	ang:RotateAroundAxis(ang:Forward(), 90)
	ang:RotateAroundAxis(ang:Right(), 90)
	
	cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.1)
		surface.SetDrawColor( 255, 255, 255, 255 )
		surface.SetMaterial(Material(self.Material, "noclamp smooth"))
		surface.DrawTexturedRect( 0, 0, 256, 256)
	cam.End3D2D()
end

Thanks in advance :smiley:

It is giving you errors because pointshop uses .mdl extensions. And plus you have it noted as a material. Each bone prop or other vars that converses with the body in GMod uses a model to attach itself to.

Here is an example of an accessory just like a mask.


ITEM.Name = '3D Glasses'
ITEM.Price = 400
ITEM.Model = 'models/gmod_tower/3dglasses.mdl'
ITEM.Bone = 'eyes'

function ITEM:OnEquip(ply, modifications)
	ply:PS_AddClientsideModel(self.ID)
end

function ITEM:OnHolster(ply)
	ply:PS_RemoveClientsideModel(self.ID)
end

function ITEM:ModifyClientsideModel(ply, model, pos, ang)
	model:SetModelScale(0.8, 0)
	pos = pos + (ang:Right() * 5) + (ang:Up() * 6) + (ang:Forward() * 2)
	
	return model, pos, ang
end

More information on MDLs.

One Last Edit:


ITEM.Name = 'Text Hat'
ITEM.Price = 1000
ITEM.Model = 'models/extras/info_speech.mdl'
ITEM.NoPreview = true

local MaxTextLength = 32

function ITEM:PostPlayerDraw(ply, modifications, ply2)
	if not ply == ply2 then return end
	if not ply:Alive() then return end
	if ply.IsSpec and ply:IsSpec() then return end
	
	local offset = Vector(0, 0, 79)
	local ang = LocalPlayer():EyeAngles()
	local pos = ply:GetPos() + offset + ang:Up()
	
	ang:RotateAroundAxis(ang:Forward(), 90)
	ang:RotateAroundAxis(ang:Right(), 90)
	
	cam.Start3D2D(pos, Angle(0, ang.y, 90), 0.1)
		draw.DrawText(string.sub(modifications.text or ply:Nick(), 1, MaxTextLength), "PS_Heading", 2, 2, modifications.color or Color(255, 255, 255, 255), TEXT_ALIGN_CENTER)
	cam.End3D2D()
end

function ITEM:Modify(modifications)
	Derma_StringRequest("Text", "What text do you want your hat to say?", "", function(text)
		modifications.text = string.sub(text, 1, MaxTextLength)
		PS:ShowColorChooser(self, modifications)
	end)
end

The pointshop can use materials. The method I’m talking about is possible. The material is treated like a model as it is 3D2D but is still referred to as a material throughout. There used to be a script on ScriptFodder/Coderhire that did png masks but I can’t find it for sale anyway and I don’t want to use a leak, so my only option is to try and make it.

Kk, I always thought it was just MDLs. Never considered PNGs to act as an working extension.
I noticed a part of the code you are missing though.


 ITEM.Bone = '(The Bone of your Choice)' 

That will attach your item to the model.

To find out which one:
Here is the GMod Documentation https://wiki.garrysmod.com/page/Entity/LookupBone