General > Developers Corner
Get a team's Color
JamminR:
Try;
--- Code: ---local r,g,b,a = v:Team():GetColor()
local ThisTeamColor = string.format( "Color: R=%i G=%i B=%i A=%i" , r, g, b, a )
ULib.tsay(ply, ThisTeamColor )
--- End code ---
Though concatenation (using periods to separate strings and lua variables .. var .. var ..) is fine for quick little tests, I suggest reading a tutorial explaining the different string.format functions.
ahref:
nope still not working. Ive moved this function into its own file and everything :(
EDIT: just tried:
--- Code: --- ULib.tsay(ply, "hello" )
local r,g,b,a = v:Team():GetColor()
ULib.tsay(ply, "hello2" )
--- End code ---
the module gets registered etc. I see the first hello message but nothing runs past the line that uses GetColor(). hello2 is not displayed
JamminR:
There should be errors in console, most likely the server, after that function is run.
If you remove GetColor and try to tsay or Print v:Team(), what are the results?
ahref:
--- Code: --- local T = v:Team()
local r,g,b,a = team.GetColor(T)
local ThisTeamColor = string.format( "Color: R=%i G=%i B=%i A=%i" , r, g, b, a )
--- End code ---
just tried this :( still nothing
also finally got a simple error message:
--- Code: ---local r,g,b,a = v:Team():GetColor()
--- End code ---
ulx/modules/test.lua:20: attempt to index a number value
JamminR:
I know I'm throwing out wild guesses, try team.GetColor( v:Team() )
v:Team():GetColor() should work as far as I know, but apparently its not.
NOTE: Actually, before making this post, I poked around sui_scoreboard to see how it did team colors for it's rows.
Though the above was a educated guess, ... sui_scoreboard uses it to set a variable.
tcolor = team.GetColor( self.Player:Team() )
And tcolor.r tcolor.g and tcolor.b are used to later set a color.
What I find confusing is the fact those are used like a table (tablename.key), but, the Gmod wiki says they aren't a table.
I may have missed a conversion function though.
Navigation
[0] Message Index
[#] Next page
[*] Previous page
Go to full version