• Print

Author Topic: Custom voice chat box  (Read 4221 times)

0 Members and 1 Guest are viewing this topic.

Offline iViscosity

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 803
  • Karma: 58
Custom voice chat box
« on: October 09, 2016, 09:23:59 am »
Hey guys, I'm using the Voice Visualizer (found here) and I was wondering if there is a way to add a new line to the box. I want it to display someone's rank under their name in the voice chat box, and right now I have this:
Code: Lua
  1.  
  2. local groups = {
  3.    { "trial", "Trial Staff" },
  4.    { "staff", "Staff" },
  5.    { "operator", "Operator" },
  6.    { "admin",    "Admin" },
  7.    { "headadmin",  "Head Admin" },
  8.    { "superadmin",  "Super Admin" },
  9.    { "viptier1", "VIP Tier 1" },
  10.    { "viptier2", "VIP Tier 2" },
  11.    { "viptierex", "VIP Tier Executive" },
  12.    { "user", "Guest" }
  13.  
  14.  
  15. }
  16.  
  17.  
  18. -- Cut out other code here
  19.  
  20.  
  21.  
  22.  
  23.  
  24. function PANEL:VVPaint(w, h)
  25.     if not IsValid(self.ply) or not self:Valid() then return end
  26.     draw.RoundedBox(4, 0, 0, w, h, vv.BackgroundColor(self, self.ply))
  27.    
  28.     for i,v in pairs(self.Past) do
  29.         local barh = v * vv.BarHeightMultiplier
  30.         local barcolor = self:GetBarColor(v * 100)
  31.         surface.SetDrawColor(barcolor)
  32.         surface.DrawRect(35 + i * (vv.BarDistance + vv.SingleBarWidth), 36 - barh, vv.SingleBarWidth, barh)
  33.     end
  34.    
  35.     -- Draw Name
  36.     surface.SetFont(vv.NameFont(self, self.ply))
  37.     local w,h = surface.GetTextSize(self.ply:Nick())
  38.    
  39.     surface.SetTextColor(vv.NameColor(self, self.ply))
  40.     surface.SetTextPos(40, 40/2 - h/2)
  41.     surface.DrawText(self.ply:Nick())
  42.  
  43.  
  44.     local ply = LocalPlayer()
  45.     local group = ply:GetUserGroup()
  46.  
  47.  
  48.     surface.SetTextColor( Color( 255, 255, 255 ) )
  49.     for k,v in pairs( groups ) do -- This I added
  50.        
  51.         if ply:IsUserGroup( v[1] ) then
  52.            
  53.             if v[1] == "superadmin" or "admin" then
  54.  
  55.  
  56.                 surface.DrawText( "[*" .. v[2] .. "]" )
  57.  
  58.  
  59.             else
  60.  
  61.  
  62.                 surface.DrawText( "[" .. v[2] .. "]" )
  63.  
  64.  
  65.             end
  66.  
  67.  
  68.         end
  69.        
  70.     end -- End of what I added
  71.  
  72. end


And right now it shows the avatar, name, and rank, but it shows the rank directly next to the name. Is there any way I can do this without having to re-write the voice chat box to make it larger?


I've tried using "\n[" but that doesn't work.
« Last Edit: October 09, 2016, 09:54:40 am by iViscosity »
I'm iViscosity. I like gaming and programming. Need some help? Shoot me PM.

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Custom voice chat box
« Reply #1 on: October 09, 2016, 11:14:34 am »
Pretty sure, no, you'll need a bigger box.
That being said, you may have the box auto adjust if you get the group text first, add it to and figure out how to have the following code line adjust horizontally
Code: [Select]
    local w,h = surface.GetTextSize(self.ply:Nick())
I'm sure someone much more experienced with GUI here could, and hopefully eventually will, help, if you're unable to figure out by tinkering on your own.
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

  • Print