• team.SetColor
    10 replies, posted
Hi! I wasn't able to find an example on how to use team.SetColor in darkrp. I was wondering if any of you guys can provide one?
After you declare the job, call team.SetColor(TEAM_ENUM, Color(255, 255, 255)).
[code] local function UnderCover( ply, text, team ) if string.sub( text, 1, 5 ) == "!hide" then local PlyTeam = ply:Team() ply:ChatPrint("Hello "..PlyTeam) if PlyTeam == 29 then ply:ChatPrint("Ran") team.SetColor(PlyTeam,Color(255,255,255)) end end end hook.Add("PlayerSay", "UnderCover", UnderCover ) [/code] Am I not declaring the job correctly?
[QUOTE=lemonhead;52631592][code] local function UnderCover( ply, text, team ) if string.sub( text, 1, 5 ) == "!hide" then local PlyTeam = ply:Team() ply:ChatPrint("Hello "..PlyTeam) if PlyTeam == 29 then ply:ChatPrint("Ran") team.SetColor(PlyTeam,Color(255,255,255)) end end end hook.Add("PlayerSay", "UnderCover", UnderCover ) [/code] Am I not declaring the job correctly?[/QUOTE] Yeah you are but, is even team.SetColor networked? I think you've got to send it to the client or something after that so it updates, i'm not sure tho, but according to the code on the thing, i don't see it being networked. You can try doing so. [URL="https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/includes/modules/team.lua#L162-L169"]Source[/URL]
I forgot to mention the error i was getting, I don't know if it matters. lua:53: attempt to index local 'team' (a boolean value)
[QUOTE=lemonhead;52631629]I forgot to mention the error i was getting, I don't know if it matters. lua:53: attempt to index local 'team' (a boolean value)[/QUOTE] Because you're overriding the Team library with the 3rd argument from the function. Rename it to something else like, isTeam instead.
Ok, I renamed the var isteam, it throws no errors, but does nothing to team color. I wouldnt know how to proceed. Edit: The name in chat changes color, the scoreboard does not.
[QUOTE=lemonhead;52631658]Ok, I renamed the var isteam, it throws no errors, but does nothing to team color. I wouldnt know how to proceed. Edit: The name in chat changes color, the scoreboard does not.[/QUOTE] [QUOTE=geferon;52631608]Yeah you are but, is even team.SetColor networked? [B]I think you've got to send it to the client or something after that so it updates, i'm not sure tho, but according to the code on the thing, i don't see it being networked. You can try doing so.[/B] [URL="https://github.com/Facepunch/garrysmod/blob/master/garrysmod/lua/includes/modules/team.lua#L162-L169"]Source[/URL][/QUOTE]
Sorry, yeah all set, I used sendlua, thanks. To set the job name, I used a timer for 3 seconds, but thats not working. [code] timer.Simple(3, function() ply:ConCommand("say /job Thief") end) [/code] Edit: I'm dumb, scoreboard not using getdarkrpvar. Thanks for your help!
You shouldn't use SendLua nor ConCommand for that: use net messages.
Sorry, lol I ended up using updateJob() anyways!
Sorry, you need to Log In to post a reply to this thread.