• team.GetColor
    7 replies, posted
I'm using this for a clientside script on darkrp. I'm a newbie. This would work before but would not show your RP name, but uses your team color. [CODE]chat.AddText(ply, Color( 255, 255, 255), ": ", txt2)[/CODE] Now when I try this, why doesn't it work? [CODE]chat.AddText(team.GetColor(ply:Team()), ply:Nick(), Color( 255, 255, 255), ": ", txt2)[/CODE] I get the following error: [CODE][ERROR] lua/autorun/client/abc.lua:5: attempt to index local 'team' (a boolean value)[/CODE] Please help! Thanks!
Seems like something is overwriting value "team" to a boolean, when it should be a table, can you show us whole code in that file at least?
If this is in an OnPlayerChat hook, you may have locally overwrote the library with a boolean that tells you whether the message is in team chat or not (I did this when I was starting out too) when declaring your arguments. Could you post the full code?
[CODE]chat.AddText( Color( team.GetColor(ply:Team()) ), ply:Nick(), Color( 255, 255, 255), ": ", txt2)[/CODE] Try that. May, or may not work.
GM:OnPlayerChat( Player ply, string text, boolean teamChat, boolean isDead ) Just found out this was the problem a while ago. .3. The teamChat argument was named "team"
[QUOTE=Triage;48217043][CODE]chat.AddText( Color( team.GetColor(ply:Team()) ), ply:Nick(), Color( 255, 255, 255), ": ", txt2)[/CODE] Try that. May, or may not work.[/QUOTE] You obviously didn't understand the error, also team.GetColor already returns it as Color. AK to Spray is probably right, example codes normally have it named "team"
[QUOTE=Newjorciks;48217092]You obviously didn't understand the error, also team.GetColor already returns it as Color. AK to Spray is probably right, example codes normally have it named "team"[/QUOTE] Didn't know it returned as a color, my bad.
Everyone answering doesn't know what they're doing.. [code] local teamcolor = team.GetColor(ply:Team()) chat.AddText( Color(teamcolor.r, teamcolor.g, teamcolor.b, 255), ply:Nick(), Color( 255, 255, 255), ": ", txt2) [/code]
Sorry, you need to Log In to post a reply to this thread.