General > Developers Corner
Get a team's Color
ahref:
I've got everything working for a custom ulx command ive been writing except that im trying to get the players team color(Im using UTeam so it thought this would be easy :()
Im using the usual code i see in all the other commands where multiple users can be used:
--- Code: --- if #argv < 1 then
ULib.tsay( ply, ulx.LOW_ARGS )
return
end
local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
if not targets then
ULib.tsay( ply, err )
return
end
for _, v in ipairs( targets ) do
ULib.tsay(ply,v:Team():GetColor())
end
--- End code ---
The code does nothing and appears to not even load. How do i get the players team color? thanks
Megiddo:
Where are you saving this code to?
ahref:
its within a function thats in a file thats in the modules directory :P.
JamminR:
According to GetColor, the value is returned as separate integers. Not even a table (I consider that odd, but, meh)
Not too sure how tsay would see that.
Perhaps try the example shown in GetColor to save to local r,g,b,a variables, then display those variables using TSay?
As for the (seemingly) not loading, perhaps add a MsgN at the bottom of your file below the functions. Basically, if the module loads correctly within ULX, your MsgN will show a message, then ULX will say it loaded (as a filename) during SP game or server startup.
ahref:
thanks it loads correctly if that line is removed. The rest of the function works its just getting the color. ive tried doing this:
--- Code: --- local r,g,b,a = v:Team():GetColor()
ULib.tsay(ply,"Color: (" .. r .. ", " .. g .. ", " .. b .. ", " .. a .. ")");
--- End code ---
this also breaks the module.
Ill try the table method
Navigation
[0] Message Index
[#] Next page
Go to full version