ULX

Author Topic: Changing Scoreboard Colors For Gmod Murder  (Read 11545 times)

0 Members and 3 Guests are viewing this topic.

Offline ZackLeim

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Changing Scoreboard Colors For Gmod Murder
« on: November 27, 2014, 04:17:29 PM »
As of writing this, I'm am working a lot to make a good Gmod Murder Server. What I figured out pretty quickly was that there is not much info on the murder gamemode. It has already taken me hours of reading through the files to do what I want, and I believe there are more hours to come. Therefore, I wanted to make this to show at least one of the things I've learned: Changing the colors on the scoreboard.

In most gmod gamemodes, there is a scoreboard which opens when you hold "tab". In Gmod murder, this is how the default setup is: Players are blue, spectators are gray and admins/superadmins are red with a wand by their name. To me that is a very dull setup. Now how can one make it cooler without having to redesign the entire gamemode?

I got the idea from another server: Having ranks and let every rank have its own color. Make a rainbow out of the <censor> scoreboard! yeah! But how? This is when I figured out that I had to find out my self. Here is what I did:


1. Get ULX!!! This is so useful that I think valve should include it in the serverfiles itself! The more extra stuff you have for you ULX, the better!!

2. Create your groups in ULX. Just go on you server and make the groups from the xgui there, it's much easier than editing files. In the server I'm making, I made 12 groups (11+users), but the only limit is how much work you want to put into it (or the memory of the disk)

3. Now it's time to edit some files! go to garrysmod\settings and open the users.txt. Here you will find this:
Code: [Select]
"superadmin"
{
//"garry" "STEAM_0:1:7099"
}

"admin"
{
//"garry" "STEAM_0:1:7099"
}
Here you just need to copy the pattern and make a line for every group. Give them the same names as the ULX groups.
Code: [Select]
"superadmin"
{
//"garry" "STEAM_0:1:7099"
}

"admin"
{
//"garry" "STEAM_0:1:7099"
}

"operator"
{
//"garry" "STEAM_0:1:7099"
}

"TrialOperator"
{
//"garry" "STEAM_0:1:7099"


"trusted"
{
//"garry" "STEAM_0:1:7099"

You do not need to care about the "garry" and the steamid, they are not important

Above all of this in the same file, it gives you a code for how to use the groups in other files (pl:IsUserGroup( "<group>" ). However, the murderfiles don't use pl to mark a player, it uses "ply". Therefor we must use "ply:IsUserGroup( "<group>" )".

4. Go to garrysmod\gamemodes\murder\gamemode and open cl_scoreboard.lua. You will be looking for this part:
Code: [Select]
if IsValid(ply) && showAdmins && ply:IsAdmin() then
surface.SetDrawColor(Color(185,174,14))

The color is not default because I have changed it, this is where we do that. But one thing at the time.

This line says that if the player is an admin/superadmin, then that person will have the color that is indicated by the three numbers. One thing that I wanted to do was to separate the two types of admins. To do that, we must change the "ply:IsAdmin()" with one line that goes for "ply:IsUserGroup("superadmin")" and one for "ply:IsUserGroup("admin")":
Code: [Select]
              if IsValid(ply) && showAdmins && ply:IsUserGroup("superadmin") then
surface.SetDrawColor(Color(185,174,14))
elseif IsValid(ply) && showAdmins && ply:IsUserGroup("admin") then
                        surface.SetDrawColor(Color(185,0,0))

If you are new to coding, do notice that only the first line have if as the first word, while the others have elseif. Here you can add a lot of lines:
Code: [Select]
if IsValid(ply) && showAdmins && ply:IsUserGroup("superadmin") then
surface.SetDrawColor(Color(185,174,14))
elseif IsValid(ply) && showAdmins && ply:IsUserGroup("admin") then
                        surface.SetDrawColor(Color(185,0,0))
elseif IsValid(ply) && showAdmins && ply:IsUserGroup("operator") then
                        surface.SetDrawColor(Color(10,111,20))
elseif IsValid(ply) && showAdmins && ply:IsUserGroup("TrialOperator") then
                        surface.SetDrawColor(Color(63,215,47))
elseif IsValid(ply) && showAdmins && ply:IsUserGroup("trusted") then
                        surface.SetDrawColor(Color(215,0,215))

5. Now we need to find the colors. The three number are the keys! They are coded after RGB (Red-Green-Blue) codes. Follow this link to find colors quickly: http://www.rapidtables.com/web/color/RGB_Color.htm
If you plot in the numbers I have for superadmins, it will show a golden color.

6. Haven't we already done what I set out to do? Yes, but there is one last thing: the wand. By default only superadmins and admins have this, but in my case, I also wanted the operators and TrialOperators to have it. To do this, we must continue to work in the cl_scoreboard.lua. First we must look for this line:
Code: [Select]
if showAdmins && ply:IsAdmin() then
surface.SetMaterial(admin)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(s + 4, h / 2 - 16, 32, 32)
s = s + 32
end

As you can see, once again we have the "ply:IsAdmin()". This means that if you wanted to, you could split them up the same way we did before, but since I want both admins and superadmins to have the wand, it serves no purpose to do that. Instead we copy the entire thing, paste them under one another and change it for the other groups.
Code: [Select]
if showAdmins && ply:IsAdmin() then
surface.SetMaterial(admin)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(s + 4, h / 2 - 16, 32, 32)
s = s + 32
end

                        if showAdmins && ply:IsUserGroup("operator") then
surface.SetMaterial(admin)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(s + 4, h / 2 - 16, 32, 32)
s = s + 32
                        end

                        if showAdmins && ply:IsUserGroup("TrialOperator") then
surface.SetMaterial(admin)
surface.SetDrawColor(color_white)
surface.DrawTexturedRect(s + 4, h / 2 - 16, 32, 32)
s = s + 32
                        end

The thing that actually adds the wand, is the line "surface.SetMaterial(admin)". If you change the word "admin" with "muted", then it will show the muted symbol for that group, but this can get confusing if you actually mute someone.



That is how to do it! It is a very manual way of doing it. I'm very new to coding myself, and to be honest, I'm not sure if step 3 is needed. However, if you include step 3, I know that it will work. The nice thing is that this works with ULX, so if you move someone to another group in-game, it will update automatically. This makes for a colorful scoreboard in gmod murder.

Hope this was understandable. Please do ask questions, although I can not guarantee a good answer.

ZackLeim


PS: Check out my murder server when I get it up and running.
IP: 185.28.189.87:27015
« Last Edit: November 28, 2014, 04:03:12 AM by ZackLeim »

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Changing Scoreboard Colors For Gmod Murder
« Reply #1 on: November 27, 2014, 09:49:22 PM »
Good writeup.
Some general notes/thoughts.
1) My general feeling is that it would be better to set colors based on team assignments, rather than groups, in any given gamemode. That's mostly my educated guestimation opinion though.
2) When you're setting users.txt groups, though, officially that's how Gmod requires it, and ULX loads that file first, you may get confused about group changes later. At the least, Gmod might.
(ULX loads settings/users.txt first, then we load 'our' ULib users.txt group file... I could see getting confused when looking at one but someone else getting another (that you or another superadmin changed but forgot or without communication))

"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming

Offline Bytewave

  • Respected Community Member
  • Hero Member
  • *****
  • Posts: 718
  • Karma: 116
  • :)
    • My Homepage
Re: Changing Scoreboard Colors For Gmod Murder
« Reply #2 on: November 27, 2014, 10:13:53 PM »
Good writeup.
Some general notes/thoughts.
1) My general feeling is that it would be better to set colors based on team assignments, rather than groups, in any given gamemode. That's mostly my educated guestimation opinion though.
2) When you're setting users.txt groups, though, officially that's how Gmod requires it, and ULX loads that file first, you may get confused about group changes later. At the least, Gmod might.
(ULX loads settings/users.txt first, then we load 'our' ULib users.txt group file... I could see getting confused when looking at one but someone else getting another (that you or another superadmin changed but forgot or without communication))


In Murder you don't want people to know who is what team, so...
bw81@ulysses-forums ~ % whoami
Homepage

Offline ZackLeim

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
Re: Changing Scoreboard Colors For Gmod Murder
« Reply #3 on: November 28, 2014, 02:18:47 AM »
Good writeup.
Some general notes/thoughts.
1) My general feeling is that it would be better to set colors based on team assignments, rather than groups, in any given gamemode. That's mostly my educated guestimation opinion though.
2) When you're setting users.txt groups, though, officially that's how Gmod requires it, and ULX loads that file first, you may get confused about group changes later. At the least, Gmod might.
(ULX loads settings/users.txt first, then we load 'our' ULib users.txt group file... I could see getting confused when looking at one but someone else getting another (that you or another superadmin changed but forgot or without communication))



The thing about murder is that murder only has two teams, player and spectator. Seeing how these are the only two teams, but admins still have the red color, I thought that it was not the way to do it. However, I did notice the garrysmod\gamemodes\murder\gamemode\shared.lua which says those teams.
Code: [Select]
team.SetUp(1, "Spectators", Color(150, 150, 150))
team.SetUp(2, "Players", Color(26, 120, 245))

One thing that came to mind was that there is a ulx command to move to spectators. It would be cool to know if it works by adding more colors here. That might give you the colors, but I'm not sure how that would go together with the ulx groups, which makes changing their "ranks" easy as f***.

When it comes to the second point: yeah, this way is a mess. If there are more that one superadmin, good communication will be needed to not f*** it up. In my case there is one other superadmin, and the only reason I know this will work, is that we talk on a daily basis.

Thanks for your reply, both Bytewave and JamminR :)

Offline JamminR

  • Ulysses Team Member
  • Hero Member
  • *****
  • Posts: 8096
  • Karma: 390
  • Sertafide Ulysses Jenius
    • Team Ulysses [ULib/ULX, other fine releases]
Re: Changing Scoreboard Colors For Gmod Murder
« Reply #4 on: November 28, 2014, 08:36:47 AM »
In Murder you don't want people to know who is what team, so...
Ah... indeed then, multiple group colors indeed wouldn't matter in the scoreboard.

there is one other superadmin, and the only reason I know this will work, is that we talk on a daily basis.
Good practice. Fewer supers, or at least full trust and communication, the better.
Seems (too) many of the DarkRP "I'm owner group so will have many under me as superadmin" variety come here with issues related to having too many superadmins that cause troubles.
« Last Edit: November 28, 2014, 08:38:37 AM by JamminR »
"Though a program be but three lines long, someday it will have to be maintained." -- The Tao of Programming