hook.Add("PlayerLoadout", "letsninjathis", function (self)
color = Vector(team.GetColor(self:Team()))
self:SetPlayerColor( color )
end )
Currently trying to figure out what I'm doing wrong here.
I got no error code in console. My player color is auto-set
to black. Kind of becoming a problem. Any assistance?
What gamemode are you using?
DarkRP
[editline]23rd November 2015[/editline]
Perhaps, I should be more specific. I want the shirt/clothes color to match the job's set Color.
Which doesn't seem to be happening.
Why is color being defined as a vector?
Found it like that on the Wiki, was confused on why it was a vector. Perhaps a spelling error?
I'll try the way it "should" be made.
[editline]23rd November 2015[/editline]
It's supposed to be defined as a Vector. Or so the error says.
It should be defined as Color() and not vector someone must have wrote the wrong thing.
Edit:
Look [URL="https://wiki.garrysmod.com/page/team/GetColor"]here[/URL] it's returned as a color structure.
Tried
ply:SetPlayerColor( Vector(team.GetColor( ply:Team() )) )
ply:SetPlayerColor( team.GetColor( ply:Team() ) <- Which obviously was not going to work.
The server see's it wrong. Nothing's wrong with it. I tried Vector(1,0,0) And my player color was set to red.
So if it is working what problem are you having?
[QUOTE=D3NNYM41C01M;49170582]Tried
ply:SetPlayerColor( Vector(team.GetColor( ply:Team() )) )
ply:SetPlayerColor( team.GetColor( ply:Team() ) <- Which obviously was not going to work.
The server see's it wrong. Nothing's wrong with it. I tried Vector(1,0,0) And my player color was set to red.[/QUOTE]
I remmember a few years ago when i first started gmod scripting, this also confused me, if i remmember right its defined as a vector, and its just RGB normalized, might be wrong though. You should try just using Entity/SetColro instead, ply:SetColor might just be depecrated.
[url]https://wiki.garrysmod.com/page/Entity/SetColor[/url]
The problem is, I'm not trying to make it set to this player color Permanently. Only when playing as drug dealer. (Purple Color) And then when they switch to another job, let's say cop (blue). I want the player model set to blue. And for anyone who uses the brain. I'm not going to do
if blah then
blah
elseif blah then
end
For each damn job. Already had someone tell me that, heck to the no!
[editline]23rd November 2015[/editline]
[QUOTE=DamienTehDemo;49170598]I remmember a few years ago when i first started gmod scripting, this also confused me, if i remmember right its defined as a vector, and its just RGB normalized, might be wrong though. You should try just using Entity/SetColro instead, ply:SetColor might just be depecrated.
[url]https://wiki.garrysmod.com/page/Entity/SetColor[/url][/QUOTE]
That shit + team.getcolor made my model Purple. (Including the face). I had a feeling it would do that, and I already did that. Wtf, why would I do it again??? Idk, tired. Lol Talking to myself in chat, that's how tired I am. LOL
in darkrp/gamemode/modules/base/sv_gamemodefunctions.lua
add
[CODE]
ply:SetColor(jobTable.color)
[/CODE]
After line 691. Tell me if that works.
Did I mention I'm using 2.4.3 Core files?
I don't use 2.5+
The gamemode functions lua file is a bit different then 2.5+
[QUOTE=D3NNYM41C01M;49170632]Did I mention I'm using 2.4.3 Core files?[/QUOTE]
OH well just put that in the PlayerLoadout function under the first jobtable variable. and change jobTAble to whatever jobtable variable is in that version. All it is doing is when the loadout is given it sets the players color to the color variable in that jobs config.
[lua]
hook.Add("PlayerLoadout", "setclothescolor", function(ply)
local color = team.GetColor( ply:Team() )
ply:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) )
end)
[/lua]
[QUOTE=Phoenixf129;49170650][code]
local color = team.GetColor( ply:Team() )
ply:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) )
[/code][/QUOTE]
He made what i said much simpler. xD. Just put that in the loadout function or on spawn function.
[QUOTE=Phoenixf129;49170650][lua]
hook.Add("PlayerLoadout", "setclothescolor", function(ply)
local color = team.GetColor( ply:Team() )
ply:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) )
end)
[/lua][/QUOTE]
Thanks for the help breh, really saved my ass. Lol
On another note, Thanks for trying to help Damian.
I put this into MakeThings.lua
Learned something today, thanks again Phoenix.
Didnt see that it was a hook, im on my phone xD , but yeah, no problem ,sorry i couldnt say waht i was trying to well enough for you to understand xP
[QUOTE=boxvader;49170556]It should be defined as Color() and not vector someone must have wrote the wrong thing.
Edit:
Look [URL="https://wiki.garrysmod.com/page/team/GetColor"]here[/URL] it's returned as a color structure.[/QUOTE]
SetPlayerColor takes a vector because it directly binds the value to the $color parameter in the player material.
[QUOTE=Phoenixf129;49170650][lua]
hook.Add("PlayerLoadout", "setclothescolor", function(ply)
local color = team.GetColor( ply:Team() )
ply:SetPlayerColor( Vector( color.r/255, color.g/255, color.b/255 ) )
end)
[/lua][/QUOTE]
You can use the Color object's :ToVector() method to shorten this a little.
[code]ply:SetPlayerColor( color:ToVector() )[/code]
Sorry, you need to Log In to post a reply to this thread.