ULX

Author Topic: ULX scoreboard and text color help TTT server  (Read 35247 times)

0 Members and 2 Guests are viewing this topic.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #15 on: August 30, 2013, 07:15:42 PM »
I got everything working now.  Boy does it look neat!  Thank you all for the help!

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #16 on: August 31, 2013, 03:33:56 AM »
I completely forgot I about this, sorry man. I had other things on my mind at the time. Although, I'm happy that you got it fixed! What did you do to fix it? (Just out of curiousity)
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: ULX scoreboard and text color help TTT server
« Reply #17 on: August 31, 2013, 05:08:11 AM »
You do not need to change default TTT files to get it working, just use a hook.

Code: [Select]
hook.Add("TTTScoreboardColorForPlayer", "RankColours", function( ply )
if ply:SteamID() == "STEAM_0:0:0000000" then
return Color( 153, 255, 255 )
end
end)

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #18 on: August 31, 2013, 06:53:30 AM »
I don't see how that would work, care to explain?
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline iSnipeu

  • Jr. Member
  • **
  • Posts: 83
  • Karma: 12
Re: ULX scoreboard and text color help TTT server
« Reply #19 on: August 31, 2013, 07:31:22 AM »
I don't see how that would work, care to explain?

TTT has hooks you can use so you don't have to edit the gamemode for general things.

Quote from: http://ttt.badking.net/guides/hooks
TTTScoreboardColorForPlayer (ply)
Client
Called to determine what colour a player's name should be on the scoreboard. Hence, it must return a Color object, or return nil (or nothing at all). The "ply" parameter contains a player object, so you can for example check the player's SteamID and give certain people a special colour. Note that TTT also uses this hook for the default colours, so you should return nil for players that you do not want to do anything special with.
http://ttt.badking.net/guides/hooks

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #20 on: August 31, 2013, 09:40:13 AM »
Oh yeah, forgot about that hook.

Although, if he wanted that other column with the "Rank" or whatever, one would still need to modify the files.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #21 on: August 31, 2013, 03:14:07 PM »
i actually did not need to do much.  It wasnt working at first and giving me console errors, i navigated to the lines that were generating the lua errors and simply made some minor edits.  (had some extra end's)

As far as making the rank column not over lap, i just got rid of the Super Admin text and edited it to read Owner.  Now all group names fit and i dont need to meddle around to much with the script.  All i need to do now is add an extra group to get rid of the "rank" group for normal users.  Should be easy enough now that i understand how the script works in those lines.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #22 on: August 31, 2013, 03:37:05 PM »
That is actually an easy edit, in where the ranks are, under the ones for "admin" and "superadmin". Just add this:

Code: [Select]
        elseif ply:IsUserGroup("user") then
                self.cols[5]:SetText("Player")
                self.cols[5]:SetTextColor(Color(255, 255, 255, 255))

Edit as you would like it to be.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #23 on: August 31, 2013, 05:08:14 PM »
i thought for color white it was 0, 0, 0, 255

i have already added the user group to read Guest, i added another line for group "member" players gain member status upon registering to the forums!

actually heres a question

Here is what i got now

Code: [Select]
local namecolor = {
       default = COLOR_WHITE,
       admin = Color(220, 180, 0, 255),
       dev = Color(0, 100, 255, 255),
       test = Color(220, 0, 0, 255),
       member = Color(50, 255, 0, 255)
    };
     
    function GM:TTTScoreboardColorForPlayer(ply)
       if not IsValid(ply) then return namecolor.default end
     
       --ADD NAMECOLOURS HERE--
       if ply:SteamID() == "STEAM_0:0:xxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:0:xxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
          return namecolor.admin
       elseif ply:IsUserGroup("superadmin") then
                    return namecolor.test
   elseif ply:IsUserGroup("member") then
                    return namecolor.member    
       end
       return namecolor.default
    end

Instead of using each persons steam id for VIP specific colors... could i just do this instead

Code: [Select]
local namecolor = {
       default = COLOR_WHITE,
       admin = Color(220, 180, 0, 255),
       dev = Color(0, 100, 255, 255),
       test = Color(220, 0, 0, 255),
   member = Color(50, 255, 0, 255)
    };
     
    function GM:TTTScoreboardColorForPlayer(ply)
       if not IsValid(ply) then return namecolor.default end
     
       --ADD NAMECOLOURS HERE--
      if ply:IsUserGroup("vip") then
          return namecolor.dev
       elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
          return namecolor.admin
       elseif ply:IsUserGroup("superadmin") then
                    return namecolor.test
   elseif ply:IsUserGroup("member") then
                    return namecolor.member    
       end
       return namecolor.default
    end

It would be much easier and i wouldnt need to edit the lua for new VIPs
« Last Edit: August 31, 2013, 05:18:54 PM by DJ Mikey »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: ULX scoreboard and text color help TTT server
« Reply #24 on: August 31, 2013, 05:14:39 PM »
0 = absense of color.
255 = full range of color
000 = black
255255255 = white
:)
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #25 on: August 31, 2013, 05:15:44 PM »
Basically what JamminR said. It just ends up making sense somehow, and I don't want to mess with logic.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #26 on: August 31, 2013, 05:20:36 PM »
darn didnt see you replied, can you look at my previous post i just edited.  Thanks!  All this lua stuff is making my brain ache, just last week i knew nothing.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: ULX scoreboard and text color help TTT server
« Reply #27 on: August 31, 2013, 05:23:56 PM »
If I understood it right, all the extra Steam ID's are just VIPs, and those Steam ID's/players are in their own ULX group called "vip".

Then yes, in theory that should work completely fine as long as they're inside that ULX group.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #28 on: August 31, 2013, 05:24:42 PM »
fantastic, it just made more sense.

Offline DJ Mikey

  • Newbie
  • *
  • Posts: 17
  • Karma: 0
Re: ULX scoreboard and text color help TTT server
« Reply #29 on: September 01, 2013, 08:59:26 AM »
I am getting these following errors every time i press TAB.  It results in a crash from the server with the text "too many lua errors"

[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:207: attempt to index global 'Self' (a nil value)
  1. UpdatePlayerData - gamemodes/terrortown/gamemode/vgui/sb_row.lua:207
   2. SetPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:174
    3. AddPlayerRow - gamemodes/terrortown/gamemode/vgui/sb_team.lua:85
     4. UpdateScoreboard - gamemodes/terrortown/gamemode/vgui/sb_main.lua:273
      5. unknown - gamemodes/terrortown/gamemode/cl_scoreboard.lua:40


[ERROR] gamemodes/terrortown/gamemode/vgui/sb_row.lua:207: attempt to index global 'Self' (a nil value)
  1. UpdatePlayerData - gamemodes/terrortown/gamemode/vgui/sb_row.lua:207
   2. SetPlayer - gamemodes/terrortown/gamemode/vgui/sb_row.lua:174
    3. AddPlayerRow - gamemodes/terrortown/gamemode/vgui/sb_team.lua:85
     4. UpdateScoreboard - gamemodes/terrortown/gamemode/vgui/sb_main.lua:273
      5. unknown - gamemodes/terrortown/gamemode/vgui/sb_main.lua:153

The only script i edited was sb_row.lua
Here is what i currently have that is causing the errors

Code: [Select]


     
    ---- Scoreboard player score row, based on sandbox version
     
    include("sb_info.lua")
     
     
    local GetTranslation = LANG.GetTranslation
    local GetPTranslation = LANG.GetParamTranslation
     
     
    SB_ROW_HEIGHT = 24 --16
     
    local PANEL = {}
     
    function PANEL:Init()
       -- cannot create info card until player state is known
       self.info = nil
     
       self.open = false
     
       self.cols = {}
       self.cols[1] = vgui.Create("DLabel", self)
       self.cols[1]:SetText(GetTranslation("sb_ping"))
     
       self.cols[2] = vgui.Create("DLabel", self)
       self.cols[2]:SetText(GetTranslation("sb_deaths"))
     
       self.cols[3] = vgui.Create("DLabel", self)
       self.cols[3]:SetText(GetTranslation("sb_score"))
       
      self.cols[5] = vgui.Create("DLabel", self)
      self.cols[5]:SetText("Rank")
     
       if KARMA.IsEnabled() then
          self.cols[4] = vgui.Create("DLabel", self)
          self.cols[4]:SetText(GetTranslation("sb_karma"))
       end
     
       for _, c in ipairs(self.cols) do
          c:SetMouseInputEnabled(false)
       end
     
       self.tag = vgui.Create("DLabel", self)
       self.tag:SetText("")
       self.tag:SetMouseInputEnabled(false)
     
       self.sresult = vgui.Create("DImage", self)
       self.sresult:SetSize(16,16)
       self.sresult:SetMouseInputEnabled(false)
     
       self.avatar = vgui.Create( "AvatarImage", self )
       self.avatar:SetSize(SB_ROW_HEIGHT, SB_ROW_HEIGHT)
       self.avatar:SetMouseInputEnabled(false)
     
       self.nick = vgui.Create("DLabel", self)
       self.nick:SetMouseInputEnabled(false)
     
       self.voice = vgui.Create("DImageButton", self)
       self.voice:SetSize(16,16)
     
       self:SetCursor( "hand" )
    end
     
    ----EDIT THESE TO ADD MORE COLOURS----
    ----Example: test = COLOR_BLUE----
    ---Make sure to put a comma after each line until the end (Last one doesn't have one---
     
    local namecolor = {
       default = COLOR_WHITE,
       admin = Color(220, 180, 0, 255),
       dev = Color(0, 100, 255, 255),
       test = Color(220, 0, 0, 255),
       member = Color(50, 255, 0, 255)
    };
     
    function GM:TTTScoreboardColorForPlayer(ply)
       if not IsValid(ply) then return namecolor.default end
     
       --ADD NAMECOLOURS HERE--
       if ply:SteamID() == "STEAM_0:0:xxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:0:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxx" then
          return namecolor.dev
       elseif ply:SteamID() == "STEAM_0:1:xxxxxxxxxxx" then
          return namecolor.dev
       elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
          return namecolor.admin
       elseif ply:IsUserGroup("superadmin") then
                    return namecolor.test
       elseif ply:IsUserGroup("member") then
                    return namecolor.member
       end
       return namecolor.default
    end
     
    local function ColorForPlayer(ply)
       if IsValid(ply) then
          local c = hook.Call("TTTScoreboardColorForPlayer", GAMEMODE, ply)
     
          -- verify that we got a proper color
          if c and type(c) == "table" and c.r and c.b and c.g and c.a then
             return c
          else
             ErrorNoHalt("TTTScoreboardColorForPlayer hook returned something that isn't a color!\n")
          end
       end
       return namecolor.default
    end
     
    function PANEL:Paint()
       if not IsValid(self.Player) then return end
     
    --   if ( self.Player:GetFriendStatus() == "friend" ) then
    --      color = Color( 236, 181, 113, 255 )
    --   end
     
       local ply = self.Player
     
       if ply:IsTraitor() then
          surface.SetDrawColor(255, 0, 0, 30)
          surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT)
       elseif ply:IsDetective() then
          surface.SetDrawColor(0, 0, 255, 30)
          surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT)
       end
     
     
       if ply == LocalPlayer() then
          surface.SetDrawColor( 200, 200, 200, math.Clamp(math.sin(RealTime() * 2) * 50, 0, 100))
          surface.DrawRect(0, 0, self:GetWide(), SB_ROW_HEIGHT )
       end
     
       return true
    end
     
    function PANEL:SetPlayer(ply)
       self.Player = ply
       self.avatar:SetPlayer(ply)
     
       if not self.info then
          local g = ScoreGroup(ply)
          if g == GROUP_TERROR and ply != LocalPlayer() then
             self.info = vgui.Create("TTTScorePlayerInfoTags", self)
             self.info:SetPlayer(ply)
     
             self:InvalidateLayout()
          elseif g == GROUP_FOUND or g == GROUP_NOTFOUND then
             self.info = vgui.Create("TTTScorePlayerInfoSearch", self)
             self.info:SetPlayer(ply)
             self:InvalidateLayout()
          end
       else
          self.info:SetPlayer(ply)
     
          self:InvalidateLayout()
       end
     
       self.voice.DoClick = function()
                               if IsValid(ply) and ply != LocalPlayer() then
                                  ply:SetMuted(not ply:IsMuted())
                               end
                            end
     
       self:UpdatePlayerData()
    end
     
    function PANEL:GetPlayer() return self.Player end
     
    function PANEL:UpdatePlayerData()
       if not IsValid(self.Player) then return end
     
       local ply = self.Player
       self.cols[1]:SetText(ply:Ping())
       self.cols[2]:SetText(ply:Deaths())
       self.cols[3]:SetText(ply:Frags())
     
       if self.cols[4] then
          self.cols[4]:SetText(math.Round(ply:GetBaseKarma()))
       end
     
       self.nick:SetText(ply:Nick())
       self.nick:SizeToContents()
       self.nick:SetTextColor(ColorForPlayer(ply))
       
       
            if ply:IsUserGroup("superadmin") then
                    self.cols[5]:SetText("Owner")
                    self.cols[5]:SetTextColor(namecolor.test)
            elseif ply:IsUserGroup("admin") then
                    self.cols[5]:SetText("Admin")
                    self.cols[5]:SetTextColor(Color(220, 180, 0, 255))
            elseif ply:IsUserGroup("vip") then
                    self.cols[5]:SetText("VIP")
                    self.cols[5]:SetTextColor(Color(0, 100, 255, 255))
            elseif ply:IsUserGroup("user") then
                    self.cols[5]:SetText("Guest")
                    Self.cols[5]:SetTextColor(Color(255, 255, 255, 255))
            elseif ply:IsUserGroup("member") then
                    self.cols[5]:SetText("Member")
                    self.cols[5]:SetTextColor(Color(50, 255, 0, 255))
    --  Delete the -- and change the settings to your liking. DO NOT DELETE THE 'end'
            end
     
       local ptag = ply.sb_tag
       if ScoreGroup(ply) != GROUP_TERROR then
          ptag = nil
       end
     
       self.tag:SetText(ptag and GetTranslation(ptag.txt) or "")
       self.tag:SetTextColor(ptag and ptag.color or COLOR_WHITE)
     
       self.sresult:SetVisible(ply.search_result != nil)
     
       -- more blue if a detective searched them
       if ply.search_result and (LocalPlayer():IsDetective() or (not ply.search_result.show)) then
          self.sresult:SetImageColor(Color(200, 200, 255))
       end
     
       -- cols are likely to need re-centering
       self:LayoutColumns()
     
       if self.info then
          self.info:UpdatePlayerData()
       end
     
       if self.Player != LocalPlayer() then
          local muted = self.Player:IsMuted()
          self.voice:SetImage(muted and "icon16/sound_mute.png" or "icon16/sound.png")
       else
          self.voice:Hide()
       end
    end
     
    function PANEL:ApplySchemeSettings()
       for k,v in pairs(self.cols) do
          v:SetFont("treb_small")
          v:SetTextColor(COLOR_WHITE)
       end
     
       self.nick:SetFont("treb_small")
       self.nick:SetTextColor(ColorForPlayer(self.Player))
     
       local ptag = self.Player and self.Player.sb_tag
       self.tag:SetTextColor(ptag and ptag.color or COLOR_WHITE)
       self.tag:SetFont("treb_small")
     
       self.sresult:SetImage("icon16/magnifier.png")
       self.sresult:SetImageColor(Color(170, 170, 170, 150))
    end
     
    function PANEL:LayoutColumns()
       for k,v in ipairs(self.cols) do
          v:SizeToContents()
          v:SetPos(self:GetWide() - (50*k) - v:GetWide()/2, (SB_ROW_HEIGHT - v:GetTall()) / 2)
       end
     
       self.tag:SizeToContents()
       self.tag:SetPos(self:GetWide() - (50 * 6) - self.tag:GetWide()/2, (SB_ROW_HEIGHT - self.tag:GetTall()) / 2)
     
       self.sresult:SetPos(self:GetWide() - (50*6) - 8, (SB_ROW_HEIGHT - 16) / 2)
    end
     
    function PANEL:PerformLayout()
       self.avatar:SetPos(0,0)
       self.avatar:SetSize(SB_ROW_HEIGHT,SB_ROW_HEIGHT)
     
       if not self.open then
          self:SetSize(self:GetWide(), SB_ROW_HEIGHT)
     
          if self.info then self.info:SetVisible(false) end
       elseif self.info then
          self:SetSize(self:GetWide(), 100 + SB_ROW_HEIGHT)
     
          self.info:SetVisible(true)
          self.info:SetPos(5, SB_ROW_HEIGHT + 5)
          self.info:SetSize(self:GetWide(), 100)
          self.info:PerformLayout()
     
          self:SetSize(self:GetWide(), SB_ROW_HEIGHT + self.info:GetTall())
       end
     
       self.nick:SizeToContents()
     
       self.nick:SetPos(SB_ROW_HEIGHT + 10, (SB_ROW_HEIGHT - self.nick:GetTall()) / 2)
     
       self:LayoutColumns()
     
       self.voice:SetVisible(not self.open)
       self.voice:SetSize(16, 16)
       self.voice:DockMargin(4, 4, 4, 4)
       self.voice:Dock(RIGHT)
    end
     
    function PANEL:DoClick(x, y)
       self:SetOpen(not self.open)
    end
     
    function PANEL:SetOpen(o)
       if self.open then
          surface.PlaySound("ui/buttonclickrelease.wav")
       else
          surface.PlaySound("ui/buttonclick.wav")
       end
     
       self.open = o
     
       self:PerformLayout()
       self:GetParent():PerformLayout()
       sboard_panel:PerformLayout()
    end
     
    function PANEL:DoRightClick()
    end
     
    vgui.Register( "TTTScorePlayerRow", PANEL, "Button" )


Steam ids were xxx'd out for privacy reasons.

What in this code is causing those errors? 

Think i found it
elseif ply:IsUserGroup("user") then
                    self.cols[5]:SetText("Guest")
                    Self.cols[5]:SetTextColor(Color(255, 255, 255, 255))

capital S in self.cols.................
testing now.

Yes, nvm.. it was the capital S.  How dumb lol
« Last Edit: September 01, 2013, 09:19:06 AM by DJ Mikey »