• model color on Spawn
    12 replies, posted
Hello, i have a problem that i can not get any further. I try to open a RP server and on one job i need to recolor the playermodel so that the model is completly black when i go in this job like the ulx command color, but i dont know how cane i do this. Cane sombody help me with that. ps: sorry for my bad english
Unsure if this will work or not, but its worth a try, just add it onto the job. PlayerSpawn = function(ply) ply:SetColor( Color( 0, 0, 0 ) ) end
yes it works thank you, but when i go to a other job i am still black
Try adding this into a .lua file in garrysmod/lua/autorun/server hook.Add( "OnPlayerChangedTeam", "OnPlayerChangedTeam_ChangeColorBack", function( ply ) if( IsValid( ply ) ) then ply:SetColor( 255, 255, 255 ) end end )
Hooks/Shared/OnPlayerChangedTeam -> Reset the color (Color(255,255,255)) if it's a different job. (Also works for setting the color to black if the new job is the job you need to get modified)
It will reset it when they first change job, however on respawn it will be fixed, this could easily be fixed however by just using an if statement.
that did not work the other playermodels are now purple
Show us your code please.
now i have used this code: hook.Add( "OnPlayerChangedTeam", "OnPlayerChangedTeam_ChangeColorBack", function( ply )     if( IsValid( ply ) ) then         ply:SetColor( 255, 255, 255 )     end end )
Well, that should do absolutely nothing because you just set the players color to white after they've changed their team/job. So, as you just copy&pasted the code @BrickWall did post I will try to explain what you have to do. Hooks/Shared/OnPlayerChangedTeam takes 3 arguments: https://files.facepunch.com/forum/upload/2134/69ebfa71-f3fb-4938-8971-9fe6359900a3/opera_2019-01-06_18-45-46.png Check if the job ("after") is the job you want to modify using an IF statement and if it is just change the players ("ply") color to black (Color(0,0,0)). To reset a players color, you just have to check if the old job ("before") is the job you just modified and if it is, reset the players ("ply") color by setting it to white (Color(255,255,255)).
What do you mean it does nothing at all, it resets their color so that they do not stay black, but your method does improve on mine as it will instantly change their color.
okay thank you that you try to explan me how this work, but i still dont now what to do
Yep, I forgot that yours gets called too. Sorry for that Jobs & Freelancers · gmodstore or Beginner Tutorial Intro
Sorry, you need to Log In to post a reply to this thread.