• Adding to TTT Easy Scoreboard
    3 replies, posted
So the server I'm developing for runs the TTT Easy Scoreboard found [URL="https://github.com/rejax/TTT-EasyScoreboard"]here.[/URL] We use this addon to handle all of the custom rank colors and titles for different levels of staff and donators. This is great but having to edit the file every time we want to give someone a custom rank is not idea. To get around this I'm looking to add another section to the right click menu that this addon adds for commands. It looks like the addon just stores all the ranks in a giant array so making a function to add to this array should be easy enough. My issue is trying to grab user input for the arguments. I've worked a bit in java and python but I'm by no means proficient and this is a major learning experience for me. Can someone point me in the right direction on grabbing user input for each of the arguments? I apologize profusely if this is not the correct place to ask for something like this.
Umm, not sure what you meant... I think what you're going for is the [URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL] hook and [URL="http://wiki.garrysmod.com/page/string/find"]string.find[/URL]
You're right about it storing it in an array, but if you want to have it be modified through in-game input, you're also going to need to have it refer to a text file otherwise any changes you make while the game is running will just be reset on a map change. Your process will basically be [URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL] to read text chat input and [URL="http://wiki.garrysmod.com/page/string/find"]string.find[/URL] to search the text for the right string and splitting the args and then [URL="http://wiki.garrysmod.com/page/util/TableToJSON"]util.TableToJSON[/URL] to serialize your table with [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] to save your new serialized table. Then you're going to want to modify your scoreboard script to use [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] to load your data file and [URL="http://wiki.garrysmod.com/page/util/JSONToTable"]util.JSONToTable[/URL] to deserialize it back into a table that your script can use. There could be a better way to do it, but that's just the process I'd use. Make sure you use [URL="http://wiki.garrysmod.com/page/Player/IsAdmin"]Player:IsAdmin[/URL] or [URL="http://wiki.garrysmod.com/page/Player/IsSuperAdmin"]Player:IsSuperAdmin[/URL] so that only people with the right permissions can mess with it. You can also replace the PlayerSay and string.find by just making it a console command instead with [URL="http://wiki.garrysmod.com/page/concommand/Add"]concommand.Add[/URL].
[QUOTE=DeathWard;48722769]You're right about it storing it in an array, but if you want to have it be modified through in-game input, you're also going to need to have it refer to a text file otherwise any changes you make while the game is running will just be reset on a map change. Your process will basically be [URL="http://wiki.garrysmod.com/page/GM/PlayerSay"]PlayerSay[/URL] to read text chat input and [URL="http://wiki.garrysmod.com/page/string/find"]string.find[/URL] to search the text for the right string and splitting the args and then [URL="http://wiki.garrysmod.com/page/util/TableToJSON"]util.TableToJSON[/URL] to serialize your table with [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] to save your new serialized table. Then you're going to want to modify your scoreboard script to use [URL="http://wiki.garrysmod.com/page/file/Write"]file.Write[/URL] to load your data file and [URL="http://wiki.garrysmod.com/page/util/JSONToTable"]util.JSONToTable[/URL] to deserialize it back into a table that your script can use. There could be a better way to do it, but that's just the process I'd use. Make sure you use [URL="http://wiki.garrysmod.com/page/Player/IsAdmin"]Player:IsAdmin[/URL] or [URL="http://wiki.garrysmod.com/page/Player/IsSuperAdmin"]Player:IsSuperAdmin[/URL] so that only people with the right permissions can mess with it. You can also replace the PlayerSay and string.find by just making it a console command instead with [URL="http://wiki.garrysmod.com/page/concommand/Add"]concommand.Add[/URL].[/QUOTE] Thank you, this seems like a good starting point for me.
Sorry, you need to Log In to post a reply to this thread.