• Team GetColor?
    8 replies, posted
I am trying to create my own chat reader for rp. But I am getting errors getting the team color [lua] chat.AddText(Color(255,255,255),"(CHAT) ",Color(team.GetColor(ply:Team() )),ply:Nick(),Color(255,255,255),": "..strText) end [/lua] gives me: Hook 'PlyChat' Failed: [@lua\includes\util.lua:23] bad argument #1 to 'min' (number expected, got nil) If I try [lua] chat.AddText(Color(255,255,255),"(CHAT) ",Color(ply:Team():GetColor() ),ply:Nick(),Color(255,255,255),": "..strText) [/lua] I get this: Hook 'PlyChat' Failed: [lua\autorun\client\test_script.lua.lua:9] attempt to index a number value This is quite puzzling.
team.GetColor is already in colour format. team.GetColor(ply:Team()) is correct. Could use all code to check variables such as ply and strText.
:| [lua] Hook 'PlyChat' Failed: [@lua\includes\util.lua:23] bad argument #1 to 'min' (number expected, got nil) [/lua] edit: [lua] function Team() LocalPlayer():ChatPrint(tostring(team.GetColor(LocalPlayer():Team() ))) end concommand.Add("testcript_team",Team) [/lua] printed [lua] table: 2BC05078 [/lua] Odd.
[quote] Could use all code to check variables such as ply and strText. [/quote] From my own code... local Colour = team.GetColor(client:Team())
I don't quite understand "Could use all code to check variables" edit: Did I forget to mention this script is clientside. Would getting the color of a team work clientside?
[QUOTE=Brandan;25732297]:| [lua] Hook 'PlyChat' Failed: [@lua\includes\util.lua:23] bad argument #1 to 'min' (number expected, got nil) [/lua] edit: [lua] function Team() LocalPlayer():ChatPrint(tostring(team.GetColor(LocalPlayer():Team() ))) end concommand.Add("testcript_team",Team) [/lua] printed [lua] table: 2BC05078 [/lua] Odd.[/QUOTE] try PrintTable(team.GetColor(LocalPlayer():Team())) [quote="brandan"] I don't quite understand "Could use all code to check variables" [/quote] You never showed where other variables were defined.
[lua] if CLIENT then function PlyChat( ply, strText, Team, bPlayerIsDead ) chat.AddText(Color(255,255,255),"(CHAT) ",Color(team.GetColor(ply:Team() )),ply:Nick(),Color(255,255,255),": "..strText) end -- End function hook.Add("OnPlayerChat","PlyChat",PlyChat) -- Hook end [/lua]
[lua] if CLIENT then function PlyChat( ply, strText, Team, bPlayerIsDead ) local Colour = team.GetColor(ply:Team()) or Color(0,0,0) chat.AddText(Color(255,255,255),"(CHAT) ",Colour,ply:Nick(),Color(255,255,255),": "..strText) end -- End function hook.Add("OnPlayerChat","PlyChat",PlyChat) -- Hook end [/lua]
Thanks.
Sorry, you need to Log In to post a reply to this thread.