Hello everyone, I'm having a problem with my pointshop. I need to make my hat coloured, but everything works except the colour doesn't appear, here is my code:
[CODE]ITEM.Name = 'Unusual Fedora'
ITEM.Price = 15000
ITEM.Model = 'models/gmod_tower/fedorahat.mdl'
ITEM.Attachment = '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(1.1, 0)
pos = pos + (ang:Forward() * -3.6) + (ang:Up() * 2.5)
model:SetColor(203, 0, 245, 255)
return model, pos, ang
end[/CODE]
Can somebody please help?
The part you edited isn't actually creating/editing the model it's just returning information. You'd need to find what's calling that function and then modify it to allow for colour.
[QUOTE=Sereni;46199210]The part you edited isn't actually creating/editing the model it's just returning information. You'd need to find what's calling that function and then modify it to allow for colour.[/QUOTE]
Like supposedly I called model wrong? Because it's supposed to be Entity:SetColor and not model:SetColor but I found it somewhere where its model.
Adjust the ModifyClientsideModel function to return the colour of your choice:
[lua]function ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetModelScale(1.1, 0)
pos = pos + (ang:Forward() * -3.6) + (ang:Up() * 2.5)
local col = Color(203, 0, 245, 255)
return model, pos, ang, col
end[/lua]
Now, in cl_init.lua adjust your code (it's at the bottom) to account for this introduced colour:
[lua]model, pos, ang, col = ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetPos(pos)
model:SetAngles(ang)
model:SetRenderOrigin(pos)
model:SetRenderAngles(ang)
model:SetupBones()
model:SetColor(col) -- Add in this line
model:DrawModel()
model:SetRenderOrigin()
model:SetRenderAngles()[/lua]
Untested btw
[QUOTE=Sereni;46199329]Adjust the ModifyClientsideModel function to return the colour of your choice:
[lua]function ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetModelScale(1.1, 0)
pos = pos + (ang:Forward() * -3.6) + (ang:Up() * 2.5)
local col = Color(203, 0, 245, 255)
return model, pos, ang, col
end[/lua]
Now, in cl_init.lua adjust your code (it's at the bottom) to account for this introduced colour:
[lua]model, pos, ang, col = ITEM:ModifyClientsideModel(ply, model, pos, ang)
model:SetPos(pos)
model:SetAngles(ang)
model:SetRenderOrigin(pos)
model:SetRenderAngles(ang)
model:SetupBones()
model:SetColor(col) -- Add in this line
model:DrawModel()
model:SetRenderOrigin()
model:SetRenderAngles()[/lua]
Untested btw[/QUOTE]
Sadly, it doesn't work.
Sorry, you need to Log In to post a reply to this thread.