• Ranked based draw.RoundedBox
    11 replies, posted
Hello guys can somone say me what exactly i did wrong? i want do draw the bigger one in the color based on ulx ranks (default = Team color) and the smaller one in the color of the team (terrortown). draw.RoundedBox( 4, 0, 0, w, h, self.Color) draw.RoundedBox( 4, 2, 2, w-4, h-4, function color(ply)                    if ply:IsUserGroup("user") then                   return Color(0,0,0)                 end                 if ply:IsUserGroup("superadmin") then                   return Color(255,0,21)                 end                 if ply:IsUserGroup("admin") then                   return Color(232,146,35)                 end                 if ply:IsUserGroup("xx") then                   return Color(10,237,245)                 end                                 if ply:IsUserGroup("mod") then                   return Color(34,235,23)                 end                 if ply:IsUserGroup("xx") then                   return Color(10,237,245)                 end                 if ply:IsUserGroup("xx") then                   return Color(0,136,255)                 end                 if ply:IsUserGroup("xx") then                   return Color(10,237,245)                 end                        return Color( 52, 152, 219, 255 )        end)) end
Try something like this: local function GetULXColor(ply)   if ply:IsUserGroup("user") then     return Color(0,0,0)   end   if ply:IsUserGroup("superadmin") then     return Color(255,0,21)   end   if ply:IsUserGroup("admin") then     return Color(232,146,35)   end   if ply:IsUserGroup("xx") then     return Color(10,237,245)   end                   if ply:IsUserGroup("mod") then     return Color(34,235,23)   end   if ply:IsUserGroup("xx") then     return Color(10,237,245)   end   if ply:IsUserGroup("xx") then     return Color(0,136,255)   end   if ply:IsUserGroup("xx") then     return Color(10,237,245)   end                   return Color( 52, 152, 219, 255 )     end draw.RoundedBox( 4, 2, 2, w-4, h-4, GetULXColor(LocalPlayer()))
-- define in main chunk local function GetColour(ply)     local ug = ply:GetUserGroup()     if (ug == "x") then         return Color(255, 0, 0)     elseif (ug == "y") then         return Color(0, 255, 0)     elseif (ug == "z") then         return Color(0, 0, 255)     end     return Color(0, 0, 0) end -- call in render hook draw.RoundedBox(r, x, y, w, h, GetColour(ply))
local ulxcolor = { ["user"] = Color(0,0,0), ["admin"] = Color(255,0,0), ["superadmin"] = Color(0,255,0), ["other"] = Color(0,0,255), } draw.RoundedBox(4,2,2,w-4,h-4, ulxcolor[LocalPlayer():GetUserGroup()] or Color( 52, 152, 219, 255 )) Or you can do that
oh thx it works but it only shows the color like: im a user and and it shows everyone in Blue and if i'm a member it shows all in red. but i want to get the outer border in the color of the player and not to color all borders in his perspective inb his color. is it an client side issue?
replace LocalPlayer() by the player variable you got
ahh thx. if someone in the future is searching this.. here is my code that i used succsefully at Voice chat Graphs: THEME[ 'VoiceChatBoxPaint' ] = function( self, w, h )     if not IsValid( self.ply ) then return end     self.Color = self.ply:Team() == TEAM_SPECTATOR and Color( 200, 200, 20 ) or (self.Color or Color( 0, 200, 0 ))         local ulxcolor = {     ["user"] = Color(255,255,255),     ["admin"] = Color(255,0,0),     ["superadmin"] = HSVToColor( math.sin( 1.9*RealTime() )*128 + 127, 1, 1 ),     ["other"] = Color(235,225,255),     ["Member"] = Color(0,0,255),     ["Moderator"] = Color(203,178,55),     } draw.RoundedBox( 4, 0, 0, w, h, ulxcolor[ self.ply :GetUserGroup()] or Color( 52, 152, 219, 255 )) draw.RoundedBox( 4, 2, 2, w-4, h-4, self.Color) end
function LerpColor(frac,from,to) local col = Color( Lerp(frac,from.r,to.r), Lerp(frac,from.g,to.g), Lerp(frac,from.b,to.b), Lerp(frac,from.a,to.a) ) return col end
It seams that the value only changes after the player respawn. Is there a way to do it like a hsv color change?. THEME[ 'VoiceChatBoxPaint' ] = function( self, w, h )     if not IsValid( self.ply ) then return end     self.Color = self.ply:Team() == TEAM_SPECTATOR and Color( 200, 200, 20 ) or (self.Color or Color( 0, 200, 0 ))     function LerpColor(frac,from,to)     local col = Color(         Lerp(frac,from.r,to.r),         Lerp(frac,from.g,to.g),         Lerp(frac,from.b,to.b),         Lerp(frac,from.a,to.a)     )     return col end     local ulxcolor = {     ["user"] = Color(255,255,255),     ["admin"] = Color(255,0,0),     ["superadmin"] = HSVToColor( math.sin( 1.9*RealTime() )*128 + 127, 1, 1 ),     ["other"] = Color(235,225,255),     ["Member"] = Color(235,225,225),     ["Moderator"] = col     } This is the code in the current state.
Doesn't ULX has it's own rank color getting function? Or even is it a common one like team.GetColor? Why do you even need to write your own? local plycolor = team.GetColor( ply:Team() ) draw.RoundedBox( 4, 0, 0, w, h, self.Color ) draw.RoundedBox( 4, 2, 2, w-4, h-4, plycolor )
Ulx has one but i dind't want to F***up my script that i bought. maybe it was needed for something else at some point so idk. Now to the Flashing Color part: i got it to run from red to white and back... but how do i change the color? HSVToColor( 1 * 2 % 360, 2, math.abs(math.cos(RealTime() *1.9) *1)) i tried it with every parameter but i don't get it :/
HSVToColor(CurTime() * freq % 360, 1, 1) If you want a rainbow then use this. 'freq' is how fast it should change. I usually keep it at about 50.
Sorry, you need to Log In to post a reply to this thread.