Unable to set a custom playermodel colour

Hey!

What I am trying to do is finding a way to set a custom colour for Playermodels in the PointShop. Whatever I do, it always defaults back to the default colour, which is (255,255,255,255)
It is as if there is a timer in the TTT gamemode that sets it to that colour.

I have run “LocalPlayer():SetColor(0,0,0,255)” on myself in-game with a ULX add-on and that does not even work.

I have ttt_playercolor_mode set to 0 in my server.cfg so that is not the issue.

The playermodel supports custom-colours, by the way. I’ve tested in sandbox.


-- Here is my PointShop item code:

ITEM.Name = 'Black Spiderman'
ITEM.Price = 500
ITEM.Model = 'models/player/slow/jamis/spiderman/slow.mdl'
ITEM.ModelColor = Color(25, 75, 75, 255)

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

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

Any possible idea what is causing this?

Use ply:SetPlayerColor( Vector( r / 255, g / 255, b / 255 ) ); / SetWeaponColor is the same

[lua]// Dev concommand for setting player color
concommand.Add(“dev_plcol”, function( _p, _cmd, _args )
if ( !IsValid( _p ) || !_p:IsAdmin( ) ) then return; end
if ( !_args || !_args[ 1 ] || !_args[ 2 ] || !_args[ 3 ] ) then ErrorNoHalt( "You must type it like “dev_plcol 255 255 255"” ); return; end
_p:SetPlayerColor( Vector( _args[ 1 ] / 255, _args[ 2 ] / 255, _args[ 3 ] / 255 ) );
end );[/lua]

Use Eccid’s.


ITEM.Name = 'Crimson Lance'
ITEM.Price = 1500
ITEM.Model = 'models/player/lordvipes/bl_clance/crimsonlanceplayer.mdl'

function ITEM:OnEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
		--ply._OldColor = ply:GetPlayerColor()
	end
	if modifications.color ~= nil then
		borkolor = modifications.color
	ply:SetPlayerColor(Vector( borkolor.r / 255, borkolor.g / 255, borkolor.b / 255))
	end
	timer.Simple(2, function() ply:SetModel(self.Model) end)
end

function ITEM:OnHolster(ply)
	if ply._OldModel then
		ply:SetModel(ply._OldModel)
		ply:SetPlayerColor(Vector(0.24, 0.34, 0.41)) --Default color, I think
	end
end

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

function ITEM:OnModify(ply, modifications)
    self:OnHolster(ply)
    self:OnEquip(ply, modifications) -- adds the item back again, with new mods
end

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

Replace my model with yours of course. Make sure server.cfg has ttt_playercolor_mode 0; or 1; or 2, depending on who you ask. Eccid says 0. Scratch. says 1 or 2. With this script, each playermodel a person owns can have their own unique playercolor too.

Thanks, this is what I ended up doing.

Anything wrong with this?



ITEM.Name = 'Spiderman'
ITEM.Price = 500
ITEM.Model = 'models/player/slow/jamis/spiderman/slow.mdl'
ITEM.mColor = {25, 75, 75, 255}
ITEM.ModelColor = Color(25, 75, 75, 255)
ITEM.AllowedUserGroups = { "prime" }

function ITEM:OnEquip(ply, modifications)
	if not ply._OldModel then
		ply._OldModel = ply:GetModel()
	end
	
	timer.Simple(1, function()
		ply:SetModel(self.Model) 
		ply:SetPlayerColor(Vector(self.mColor[1]/255, self.mColor[2]/255,m.ModelColor[3]/255))
	end)
end

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