• Setting Player Colour
    2 replies, posted
Hi, making a gamemode but right now I'm not too sure where it's headed. I'm hoping to make a gamemode similar to that of Danger Zone in CS:GO with Half-Life 2 elements and mostly weapons from Half-Life 2. Right now, I'm stuck with setting up playermodel colours for the rebels more specifically since the beanie and lambda can be changed to different colours. I want it so every player in the server wears orange uniform, not the entire player model, similar to this. I've had a look on the garrysmod wiki and tried to play with both examples provided on the website in hopes to change the colour to my liking, just by copying example one's code it spawns every rebel player with the beanie and lambda colour in red. I've tried 1, 1, 0 and 255, 128, 0 and instead the colour is yellow but from what I know you can only choose 0 or 1 for colours using this method. This restricts you to red, green, blue, yellow, turquoise and pink. I'm using the first example in the code as shown below with the exact orange colour because it'll save me from calling a local function in case I don't need one to get the player colour to work. I've also tried the second example which uses much more specific vectors but it seems that this doesn't work at all and gives me the default colours. Both called as a local function or a normal function. In theory, this should allow you to use any colour (~16.8 million colours). Lastly, I seeked out to an old thread from just over five years ago which I also tried and I could change the colour of the beanie and lambda but the face also changes colour which I don't want. Here is my code for those willing to take a gander and give me a hand, AddCSLuaFile("cl_init.lua") AddCSLuaFile("shared.lua") include ("shared.lua") --Spawning function GM:PlayerSpawn( ply ) ply:SetPlayerColor( Vector( 255, 128, 0 ) ); ply:StripAmmo() ply:StripWeapons() ply:Give("weapon_fists") ply:SetTeam( 1 ) ply:SetHealth( 120 ) ply:SetMaxHealth( 120 ) ply:SetWalkSpeed( 150 ) ply:SetRunSpeed( 250 ) ply:SetCrouchedWalkSpeed( 0.3 ) --This determines if player spawns as male or female if math.random( 1,2 ) == 1 then ply:SetModel(table.Random(playermodelsmale) ) ply:SetupHands() ply.sex="male" print( ""..ply:GetName().." spawned as male Rebel" ) else ply:SetModel(table.Random(playermodelsfemale) ) ply:SetupHands() ply.sex="female" print( ""..ply:GetName().." spawned as female Rebel" ) end end --Fall damage function GM:GetFallDamage( ply, speed ) return math.max( 0, math.ceil( 0.2418 * speed - 141.75 ) ) end Thanks in advance.
ply:SetPlayerColor( Vector( 0, 0, 0 ) ) -sets player color to black Player/SetPlayerColor matproxy.Add You should look into material proxies as well so you can change them on the fly unless you plan on setting and forgetting.
The part of the model that is colored is determined by the model itself, and is different for each model. That means that if model have part that can be colored the function will colored it (As in player model menu in GMod) You can try Entity:SetColor, if you need to color whole model
Sorry, you need to Log In to post a reply to this thread.