Changing whole player model's color

I need to change the full player model’s color instead of just individual pieces of their armor and have been battling with this since gmod13 came out. I understand the concepts of how it is now using the alpha channel of the models texture to decide what to change the color on. Is there anyway to get around this other than creating a custom model with a modified texture?

Given the large amount of different player models I need to use in my gamemode, it isn’t really possible to find models which color nicely and players are used to associated a model with a specific class.

Server-side:
[lua]Player:SetColor( Color( 255, 0, 0, 255 ) );[/lua]

Be warned, this colors EVERYTHING. Skin, clothing, everything; as asked.

You could try tricks to make a clothing system in order to have your existing system color decently, but the Alpha system is fantastic!

That is what I’m currently doing and it is only coloring bits of clothing. I also tried SetPlayerColor(Vector) and it did not color the whole player.

I am not looking to have a clothing system, just using the HL2 and CSS models and and trying to color the whole player.

Have you tried changing the rendermode? Might not help but it is worth a shot.

What game-mode are you running? If it’s not coloring the entire player; you may be running a game-mode which splits up the character. For example; Tiramisu chops the player up into a head, body and possibly limbs as well. This could create the situation you’re in where you try targeting the player, yet only one of the body parts is targeted.

It would help to know this.

the base gamemode splits hands into a separate entity by default, you use player:GetHands() to get an entity ‘gmod_hands’ which you should be able to set the material of like no other entity… But that doesn’t seem to be working for the OP.

Correct; but he’s trying to color the entire model, the third-person model. He calls SetColor on the Player entity server-side, and only a part is colored. On base, if you SetColor on the Player, the entire model is colored including skin and all. That’s why I’m wondering if he’s running Tiramisu or some other game-mode which splits the body into separate pieces for clothing system.

you’re right, I’m confusing this thread with the other guy asking how to change hand colours, oops.

Not to be rude, but if you guys would read the fucking thread you would realize that the issue came up due to Gmod 13. Before Gmod 13, SetColor would set the entire playermodel to a certain color. After Gmod 13, both SetColor and PlayerSetColor would only change the color on certain parts of the body like only the skin.

The type of gamemode it is is irrelevant.

This is incorrect. In base, SetColor would only set the color of certain parts of the body as I mentioned above.

I don’t think saying not to be rude, and then being rude, then proving your point is fair. If you are going to be rude claim up to it.
I remember messing with coloring of a player, and eventually materials of the player. using a gamemode with sandbox base on Gmod 13, and the server call to set the players color turned them purple all over, not just coloring their clothing.

I believe SetColor sets any entity color, just like using the color tool in sandbox. SetPlayerColor is equivalent to the shirt or accent color, also the color of your physgun.
So it is possible, and I believe I used SetColor.

Do you happen to have screenshots of this being done successfully? SetColor does not work for us in the way it supposedly works for you.

I’m busy now, later I can setup an example with a screenshot and code if you like.

That’ll be unnecessary because you’re incorrect. I just figured out how to do it sort of.

When I use SetColor, I only change the skin of the player.
When I use SetPlayerColor, I only change the clothes of the player.

When I use both, I color the entire player.

This doesn’t work for most playermodels though.


ply:SetColor( Color( 255, 0, 0, 255 ))
	ply:SetPlayerColor( Vector( 255, 0, 0 ))

http://cloud-2.steampowered.com/ugc/883003003622608092/F4D2BBBCB594DCEFA93FD30BCAB3BE39200FD6CB/

This is a custom gamemode that I’ve been working on for the past couple years.

If you want to test it yourself just do ‘lua_run Entity(1):SetColor(Color(255,0,0,255))’ and you can see what is colored if you go into thirdperson mode. Or do SetPlayerColor(Vector(1,0,0)). Or go into single player and open up your context menu and change the color of different player models in that, which uses SetColor only.

Quick SERVER concommands
[lua] concommand.Add(“dev_setcolor”, function( ply, cmd, args )
ply:SetColor( Color( tonumber( args[ 1 ] ), tonumber( args[ 2 ] ), tonumber( args[ 3 ] ), tonumber( args[ 4 ] ) ) )
end )
concommand.Add(“dev_setpcolor”, function( ply, cmd, args )
ply:SetPlayerColor( Vector( tonumber( args[ 1 ] ) / 255, tonumber( args[ 2 ] ) / 255, tonumber( args[ 3 ] ) / 255, tonumber( args[ 4 ] ) / 255 ) )
end )
[/lua]

I had mixed results; Interesting…

So, when I SetPlayerColor to Blue, the admin-on-duty color, and then set the player color. Some models work, others only do a small portion. On some that do the entire model, it sometimes flickers.

Sometimes, when setting the color as admin, it removes it; this may be part of my admin coloration system, or it could be part of the halo system issue.

There seems to be a bug, though, with SetColor. I see the OPs point. Sometimes it works, sometimes it overlays on top of SetPlayerColor even on a model that didn’t work with it before, etc etc. Sometimes just running or hopping around it flickers. It’s a type of overlay / stencil maybe. Maybe we can duplicate it in code without SetColor being needed.

I won’t post the imgs, but here are links.

When admin mode is enabled, the color is reset the blue. When it’s disabled, it’s set to the previous color, if set, or blue as it’s the admin character; which is “always on duty”/ halo is the “look at me”.

Barney: Default color, set color red – ONLY FACE: http://cloud-2.steampowered.com/ugc/505826534893988387/63900D398BE0787EF036DBFD72A99AA1FE4DE03E/

Male medic random number, set color red – entire body!: http://cloud-2.steampowered.com/ugc/505826534893986572/F69B6340A3AD614FFE7EB4CBB3DF7384B5CC2430/

Male medic, standard color – http://cloud-4.steampowered.com/ugc/505826534893982576/D6DFA2F1086F7FA4296E397D7BEBAD344E488DCD/

Breen, standard idle blue admin color: http://cloud-4.steampowered.com/ugc/505826534893977563/DE8ED8E226132D43801C3929DC0969A64EE04A6C/

Breen, set color red – entire body it seems as though it overlayed the blue: http://cloud-2.steampowered.com/ugc/505826534893979903/A56B35696A55E09B01A9F58694D309237174B3BA/

Edit: Added player color vector; When I color Breen player color white, then apply normal SetColor it works fine.

Still same issue; some models play nicely; others don’t.

Aha! Figured it out mostly!

Here is Kleiner using SetColor and SetPlayerColor: PIC
Here is Kleiner after my fix: PIC

I had to change the $blendtintbybasealpha material value to 0 prior to drawing the player model. Now the problem is trying to figure out what material goes with what player model as I need to reference it directly in the code. Sadly, it looks like it might have to be hardcoded for each model as I can’t figure out a way to pull the information off the model. Player:GetMaterial() doesn’t return anything.

EDIT:
Here’s the code I was using for testing purposes. Currently I’m doing it in the PrePlayerDraw hook but I’m almost positive that changing the value only needs to be done once. So I should probably do it when a player spawns or when their model changes. The color2 and blendtintcoloroverbase are not needed, I just had them in there while testing. Although changing blendtintcoloroverbase to something other that 0 is pretty fun. Putting it to something like 100 makes them a very bright color.

[lua]
hook.Add(“PrePlayerDraw”, “PrePlayerColorOverride”, function(ply)

local r = 0
local g = 255
local b = 0
local a = 255

ply:SetPlayerColor(Vector(r/255,g/255,b/255))
ply:SetColor(Color(r,g,b))

local mat = Material(“models/kleiner/players_sheet”)
mat:SetString("$blendtintbybasealpha", “0”)
mat:SetString("$blendtintcoloroverbase", “0”)
– mat:SetString("$color2", “{0 0 0}”)
mat:Recompute( )
end)
[/lua]

-snip- I’m guessing you just edited that in, otherwise I am blind.