General > Developers Corner

ULX scoreboard and text color help TTT server

<< < (2/7) > >>

Decicus:
I have a topic related to this, one of my replies should have a download for the files (should be gamemodes/terrortown/gamemode/vgui/ in the archive, more specifically sb_row.lua & sb_main.lua). Take a look at it, and I'll (attempt to) help you out with anything you need.

DJ Mikey:
ok i think i know what to do with the sb_row.lua
Im going to wing it here, the code Stickly posted that fixed your issue gets placed in sb_main.lua   What line am i looking for?  If i am wrong i may need a more detailed walk through ):

Again thank you for your time.

Decicus:
I forgot to post the link (sorry about that), but I found the original post that I got this from. My edited one is a bit more complicated, but if you wish you can look up "Scoreboard Help" (thread) on the forums. Although, this should still work for you, unless you want specific ranks for each player: http://www.zombiemaster.org/smf/index.php?topic=11877.0

I recommend following the steps from reply #11. He makes the scoreboard look nicer.

DJ Mikey:
ah i see, that post 11 is only for making the scoreboard look better, so all i need to do is replace my files with what is in the original thread and i should be all set.  Thank you very much, ill do this asap and confirm whether it worked or not here.

Ok i may have done something wrong, it does not appear to be working.  What im trying to do is create special colors for 3 different groups, Vip, Super admin, Admin. 
I have added the sb_row.lua and sb_main.lua to my terrortown/gamemode/vgui folder, yet see nothing.  I even went and added the superadmin and vip groups to the sb_row.lua with the corresponding color id like it to be.v  I also do not see scoreboard ranks.

I also got this error

Warning: vgui.Create failed to create the VGUI component (TTTScorePlayerRow)

[ERROR] gamemodes/terrortown/gamemode/vgui/sb_team.lua:85: attempt to index local 'row' (a nil value)
  1. AddPlayerRow - gamemodes/terrortown/gamemode/vgui/sb_team.lua:85
   2. UpdateScoreboard - gamemodes/terrortown/gamemode/vgui/sb_main.lua:270
    3. Init - gamemodes/terrortown/gamemode/vgui/sb_main.lua:140
     4. Create - lua/includes/extensions/client/panel/scriptedpanels.lua:153
      5. ScoreboardCreate - gamemodes/terrortown/gamemode/cl_scoreboard.lua:27
       6. unknown - gamemodes/terrortown/gamemode/cl_scoreboard.lua:34

Disconnect: "Too many Lua Errors! Sorry!".
Disconnect: "Too many Lua Errors! Sorry!".





Ok im going to give this a shot. 
Here is what the lines look like defualt

local namecolor = {
   default = COLOR_WHITE,
   admin = Color(220, 180, 0, 255),
   dev = Color(100, 240, 105, 255),
   test = COLOR_BLUE
};

function GM:TTTScoreboardColorForPlayer(ply)
   if not IsValid(ply) then return namecolor.default end

   --ADD NAMECOLOURS HERE--
   if ply:SteamID() == "STEAM_0:0:1963640" 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
   end
   return namecolor.default
in order for me to add vip and admin im siply making this changes?

local namecolor = {
   default = COLOR_WHITE,
   admin = Color(220, 180, 0, 255),
   vip = Color(100, 240, 105, 255),
   test = COLOR_BLUE
};

function GM:TTTScoreboardColorForPlayer(ply)
   if not IsValid(ply) then return namecolor.default end

   --ADD NAMECOLOURS HERE--
   if ply:SteamID() == "STEAM_0:0:000000" then
      return namecolor.vip
   elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
      return namecolor.admin
   elseif ply:IsUserGroup("superadmin") then
       return namecolor.test

   end
   return namecolor.default
How would add more steam ids to the "vip" section.

Edit: i have reverted back to my back up sb_main and sb_row files for the time being.  I intend to have alot of people on my server tonight and do not wish to break anything before this event.  I have all these snipits of code but have no idea where to put it.  I cant imagine sb_row.lua is the only file i need to be editing.

Decicus:
This should work for the names:

--- Code: ---local namecolor = {
   default = COLOR_WHITE,
   admin = Color(225, 255, 255, 255),
   dev = Color(255, 255, 255, 255),
   vip = Color(240, 255, 10, 255),
};
 
function GM:TTTScoreboardColorForPlayer(ply)
   if not IsValid(ply) then return namecolor.default end
 
   --ADD NAMECOLOURS HERE--
if ply:SteamID() == "STEAM_0:0:1963640" then --Change Steam ID
return namecolor.vip
elseif ply:SteamID() == "STEAM_0:1:00110011" then --Change SteamID
return namecolor.vip
elseif ply:SteamID() == "STEAM_0:1:11111111" then --Change SteamID
return namecolor.vip
elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.admin
elseif ply:IsUserGroup("superadmin") then
return namecolor.admin
   end
   return namecolor.default
end

--- End code ---

Alternatively, you could do this:


--- Code: ---local namecolor = {
   default = COLOR_WHITE,
   admin = Color(225, 255, 255, 255),
   dev = Color(255, 255, 255, 255),
   vipcolor = Color(240, 255, 10, 255),
};

local Vip = {
["STEAM_0:11223344"] = true, --Test1
["STEAM_0:44332211"] = true, --Test2
["STEAM_0:12345678"] = true, --Test3
}

function GM:TTTScoreboardColorForPlayer(ply)
if not IsValid(ply) then return namecolor.default end
local vip = Vip[ply:SteamID()]
   --ADD NAMECOLOURS HERE--
if vip then
return namecolor.vipcolor
elseif ply:IsAdmin() and GetGlobalBool("ttt_highlight_admins", true) then
return namecolor.admin
elseif ply:IsUserGroup("superadmin") then
return namecolor.admin
   end
   return namecolor.default
end

--- End code ---
Inside "local Vip" change the Steam IDs inside the quotes, or add more depending on what you want. This way, you don't have to do the whole "ply:SteamID() == "STEAM_0:0:0000000"" in the function, you just add under that. I personally like this method, because it looks more clean, but you decide what you want to use.

This only modifies the names though, if you want to add ranks in it's own row in the scoreboard, you need to look at the function called "PANEL:UpdatePlayerData". Should be in line 180 (or close to that)

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version