ULX

Author Topic: [TTT] Scoreboard Ranks for ULX - Version 1.2.0  (Read 71317 times)

0 Members and 1 Guest are viewing this topic.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #15 on: December 12, 2015, 11:46:54 AM »
I just wanted to add my input, when this happened to me, refreshing the ranks showed the MIA and KIA sections, but it wasn't moving some players into them when they were killed.

That is... interesting. It unfortunately only makes me even more confused though.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline monkeymacman

  • Newbie
  • *
  • Posts: 44
  • Karma: 13
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #16 on: January 18, 2016, 08:51:48 PM »
I know it's been more or less a month since a comment was on this addon, and it also already has problems with it not working properly, but just wanted to say, you can easily change the player's name color without changing core files by using the hook TTTScoreboardColorForPlayer (ply) .

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #17 on: January 18, 2016, 10:06:44 PM »
I know it's been more or less a month since a comment was on this addon, and it also already has problems with it not working properly, but just wanted to say, you can easily change the player's name color without changing core files by using the hook TTTScoreboardColorForPlayer (ply) .
My previous replies about the matter has just been me being misinformed. I believe someone emailed me pointing out that this hook exists. I was planning on adding that feature for 1.2, but I just haven't gotten around to developing it yet due to other distractions.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline Desasterx3

  • Newbie
  • *
  • Posts: 18
  • Karma: -1
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #18 on: February 11, 2016, 05:03:54 AM »
Can you edit the ranks in a file aswell? like on Easy Scoreboard by Rejax. I´d like to use this Version as its a ULX one, but im not sure if theres a file where you can directly edit ranks.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #19 on: February 11, 2016, 06:55:35 AM »
Can you edit the ranks in a file aswell? like on Easy Scoreboard by Rejax. I´d like to use this Version as its a ULX one, but im not sure if theres a file where you can directly edit ranks.
It's possible, but I don't recommend doing so.

All ranks are saved in a JSON-format inside <Garry's Mod server directory>/data/ttt_sb_ranks/ranks.txt

The file will probably look something like this:
Code: [Select]
{"STEAM_0:1:87654321":{"b":0,"color":"colors","r":0,"text":"Colors #1","g":255},"STEAM_0:1:12345678":{"b":0,"color":"rainbow","r":0,"text":"Rainbow #1","g":0}}
You can copy/paste all of this into something like JSBeautifier, so it's a bit easier to read.
Doing so, it looks something like this:
Code: [Select]
{
    "STEAM_0:1:87654321": {
        "b": 0,
        "color": "colors",
        "r": 0,
        "text": "Colors #1",
        "g": 255
    },
    "STEAM_0:1:12345678": {
        "b": 0,
        "color": "rainbow",
        "r": 0,
        "text": "Rainbow #1",
        "g": 0
    }
}

And you can manually edit it this way (and run "ulx refreshranks") after editing it to update it on the server.
Keep in mind that you need to follow the proper JSON syntax 100%, as a typing error could mess up the whole ranks file.

But please, if you plan on editing any of the files used by this addon, back them up first.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline GG142

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #20 on: February 14, 2016, 11:33:26 PM »
So, I'm having the same problem, but might be able to give a little extra info;
So it all starts after server restart/map change. First of all, the 'rank' column width resets to 60, even if I set it to something else in the sv_tttsbranks.lua file, or with the column width command. And even weirder; the actual tags stay in the same position.
So say I've set the column width to 200, after a map change the rank column will reset to 60, but the tags will stay in the 200 position.
And then of course the entire I can't see CD or MIA people problem. All these problems seem to go away for everyone after I either update the column width with the ULX command, or refresh the ranks.

I'm currently trying to fix this in the code aswell, but without progress so far.
Good luck! :P

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #21 on: February 15, 2016, 12:03:51 AM »
So, I'm having the same problem, but might be able to give a little extra info;
So it all starts after server restart/map change. First of all, the 'rank' column width resets to 60, even if I set it to something else in the sv_tttsbranks.lua file, or with the column width command. And even weirder; the actual tags stay in the same position.
So say I've set the column width to 200, after a map change the rank column will reset to 60, but the tags will stay in the 200 position.
And then of course the entire I can't see CD or MIA people problem. All these problems seem to go away for everyone after I either update the column width with the ULX command, or refresh the ranks.

I'm currently trying to fix this in the code aswell, but without progress so far.
Good luck! :P

I never really checked if the issue happened over a mapchange, but I'll do that when I have time later today. Thanks for letting me know.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline GG142

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #22 on: February 15, 2016, 01:33:27 AM »
So uh, holy shite; I found the start of a fix.

Basicly, in the ttt_sb_ranks.lua file, in a new line under the hook.add statement underneath the END of the refresh function, just call the refresh function.
It fixes the problem after server restart, but after map change things will go baad again.
I know that this is a very edgy way of doing things, but it works :P

Anyone not knowing lua, in the file called ttt_sb_ranks.lua there should be this, somewhere around line 18.
Code: [Select]
local function TTTSBRanksRefresh( ply )

    if not ULib.fileExists( dir ) then ULib.fileCreateDir( dir ) end
    if ULib.fileRead( dir .. ranks ) then TTTSBRanks = util.JSONToTable( ULib.fileRead( dir .. ranks ) ) end
    if ULib.fileRead( dir .. settings ) then TTTSBSettings = util.JSONToTable( ULib.fileRead( dir .. settings ) ) end
    if ULib.fileRead( dir .. groups ) then TTTSBGroups = util.JSONToTable( ULib.fileRead( dir .. groups ) ) end

    if SERVER then

        net.Start( "ULX_TTTSBRanks" )
        net.WriteTable( TTTSBRanks )
        net.WriteTable( TTTSBSettings )
        net.WriteTable( TTTSBGroups )
        if ply then

            net.Send( ply )

        else

            net.Broadcast()

        end

    end

end
hook.Add( "PlayerInitialSpawn", "ULXTTTRefresh_PlayerJoin", TTTSBRanksRefresh )
Simply add
Code: [Select]
TTTSBRanksRefresh() underneath that.
« Last Edit: February 15, 2016, 03:56:12 AM by GG142 »

Offline GG142

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #23 on: February 15, 2016, 04:22:25 AM »
Found a complete fix;
Code: [Select]
local TTTSBGroups = {}

local function TTTSBRanksRefresh( ply )

    if not ULib.fileExists( dir ) then ULib.fileCreateDir( dir ) end
    if ULib.fileRead( dir .. ranks ) then TTTSBRanks = util.JSONToTable( ULib.fileRead( dir .. ranks ) ) end
    if ULib.fileRead( dir .. settings ) then TTTSBSettings = util.JSONToTable( ULib.fileRead( dir .. settings ) ) end
    if ULib.fileRead( dir .. groups ) then TTTSBGroups = util.JSONToTable( ULib.fileRead( dir .. groups ) ) end

    if SERVER then

        net.Start( "ULX_TTTSBRanks" )
        net.WriteTable( TTTSBRanks )
        net.WriteTable( TTTSBSettings )
        net.WriteTable( TTTSBGroups )
        if ply then

            net.Send( ply )

        else

            net.Broadcast()

        end

    end

end

function dirtyhack(ply)
MsgN( ply:Nick() .. " has spawned!" )
TTTSBRanksRefresh()
end
hook.Add( "PlayerInitialSpawn", "ULXTTTRefresh_PlayerJoin", TTTSBRanksRefresh )
hook.Add( "PlayerSpawn", "ulxttt_dirtyhack", dirtyhack )
Simply create another function, calling TTTSBRanksRefresh() but then with the hook "PlayerSpawn". :D ('Dirtyhack' is just a placeholder. Also, Decicus; consider adding this in the actual release ;) )

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #24 on: February 15, 2016, 05:01:30 AM »
Found a complete fix;
-snip-
Simply create another function, calling TTTSBRanksRefresh() but then with the hook "PlayerSpawn". :D ('Dirtyhack' is just a placeholder. Also, Decicus; consider adding this in the actual release ;) )

Yeah... I already had the idea of doing it for each PlayerSpawn, but then it could potentially be called too often and in worst cases someone might notice lag (even for a split second for each spawn, but still somewhat annoying).
Although, I think implementing a similar hook for the first round after a mapchange using TTTBeginRound might be a possible fix.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline GG142

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #25 on: February 15, 2016, 05:05:26 AM »
Yeah... I already had the idea of doing it for each PlayerSpawn, but then it could potentially be called too often and in worst cases someone might notice lag (even for a split second for each spawn, but still somewhat annoying).
Although, I think implementing a similar hook for the first round after a mapchange using TTTBeginRound might be a possible fix.
Good! And I do agree on the point of the annoying lag spikes, but the scoreboard works :)
Still wondering why the problem was here in the first place...

Offline monkeymacman

  • Newbie
  • *
  • Posts: 44
  • Karma: 13
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #26 on: February 15, 2016, 09:34:36 PM »
I feel like it must have something to do with you using gamemode.call("CreateScoreboard") or whatever but I am unfamiliar with the function. Also, why must you resend the whole file when something is updated? Why not just send what you are adding. Also, I don't see why refreshscoreboard would make the scoreboard work for the whole map because (unless this is a recently added part but I don't think so) it refreshes the scoreboard for a player on playerinitialspawn, so that might just be too early of a hook, but IDK in like 50% of the addon I have no clue why you are doing something.

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #27 on: February 15, 2016, 10:20:58 PM »
I feel like it must have something to do with you using gamemode.call("CreateScoreboard") or whatever but I am unfamiliar with the function.

It's possible. I believe I added that as just a quick hack a long time ago when I noticed the scoreboard would bug out if I refreshed the scoreboard.

Also, why must you resend the whole file when something is updated? Why not just send what you are adding. Also, I don't see why refreshscoreboard would make the scoreboard work for the whole map because (unless this is a recently added part but I don't think so) it refreshes the scoreboard for a player on playerinitialspawn, so that might just be too early of a hook, but IDK in like 50% of the addon I have no clue why you are doing something.

That is mainly due to poor practices that I decided to do roughly a year ago when I started this. Over time I've realized that it's honestly a pretty bad addon, as it has become more of a hassle to maintain. Personally I don't really have the time or interest in rewriting this from scratch as I don't actually play Garry's Mod or TTT anymore, even if it would probably be easier than trying to maintain it.

PlayerInitialSpawn might be too early of a hook, I agree. I could possibly look into a different hook for this usage, but for, I might just refresh it on the beginning of a round (as well as the PlayerInitialSpawn) to see if that fixes it.
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.

Offline GG142

  • Newbie
  • *
  • Posts: 5
  • Karma: 0
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1
« Reply #28 on: February 16, 2016, 12:30:07 AM »
The following seems to work for us, we hardly notice any lag spikes when people join, but maybe another hook would be nice;
Code: [Select]
local function TTTSBRanksRefresh( ply )

    if not ULib.fileExists( dir ) then ULib.fileCreateDir( dir ) end
    if ULib.fileRead( dir .. ranks ) then TTTSBRanks = util.JSONToTable( ULib.fileRead( dir .. ranks ) ) end
    if ULib.fileRead( dir .. settings ) then TTTSBSettings = util.JSONToTable( ULib.fileRead( dir .. settings ) ) end
    if ULib.fileRead( dir .. groups ) then TTTSBGroups = util.JSONToTable( ULib.fileRead( dir .. groups ) ) end

    if SERVER then

        net.Start( "ULX_TTTSBRanks" )
        net.WriteTable( TTTSBRanks )
        net.WriteTable( TTTSBSettings )
        net.WriteTable( TTTSBGroups )
        if ply then

            net.Send( ply )

        else

            net.Broadcast()

        end

    end

end
hook.Add( "PlayerInitialSpawn", "ULXTTTRefresh_PlayerJoin", TTTSBRanksRefresh )
function RefreshStart(ply)
MsgN( ply:Nick() .. " has spawned!" )
TTTSBRanksRefresh()
end
hook.Add( "PlayerSpawn", "ulxttt_RefreshStart", RefreshStart )

Offline Decicus

  • Hero Member
  • *****
  • Posts: 552
  • Karma: 81
    • Alex Thomassen
Re: [TTT] Scoreboard Ranks for ULX - Version 1.1.1
« Reply #29 on: May 18, 2016, 07:36:58 AM »
Updated to version 1.1.1 with a hotfix that GG142 provided.

Sorry it took so long.

Further updates may or may not occur as I have don't have much interested in maintaining this. If you can find a better alternative, then please feel free to use that.
If anyone wishes to continue the work for some odd reason, the source is available on GitHub, but I highly recommend rewriting this from scratch instead of continuing from my old work.
« Last Edit: May 18, 2016, 07:39:49 AM by Decicus »
Contact information:
E-mail: alex@thomassen.xyz.
You can also send a PM.