Ranks script

Alright, so I guess I’ll explain the situation first. I am friends with the owner of multiple Garry’s Mod server and he is looking for a script made. The script will change the ranks of staff members according to what server they are on. If a player is an admin on the TTT server, and he joins Prop Hunt, he will be given the “Janitor” rank (this server’s moderator). I have not written anything in Lua in over 6 months and just wanted to ask some of you whether my script will work. I can not test it on the servers because, among other things, I can not access the files and the owner does not have time to keep uploading new versions with bug fixes.
So I guess there is a second question here. Is it possible for me to add ULX to my Garry’s Mod and test the script from single player?

local server = “TTT”–The server this script is working with {“TTT”, “JB”, “DR”, ect.}

local ranks = {}
local staff = {}

function createArrays()
–Do these dynamically, or as I have. Could possibly be read from ULX
ranks[“Owner”] = 1000
ranks[“Founder”] = 900
ranks[“Manager”] = 800
ranks[“Sr. Admin”] = 700
ranks[“Admin”] = 600
ranks[“Janitor”] = 500
ranks[“Trusted”] = 400
ranks[“Donator”] = 3000 – 3000 because you should never get this rank, and it is always global.

--Make a text file, read this from there. Edit ULib.ucl.addUser/removeUser and make it write to the file to save ranks
staff["STEAM_0:0:78563137"] = "Owner,*"--Set Hippo as owner, on all (*) servers
staff["STEAM_0:0:78563136"] = "Admin,TTT"--Set Test1 as admin, on TTT
staff["STEAM_0:0:78563135"] = "Admin,JB"--Set Test1 as admin, on JB

	Since this server is "TTT" (see 'server' valiable), when Test1 one joins he will be an admin.
	However, when Test2 joins he will be a janitor as it is the next rank below admin.
	Hippo will be owner on all (*) servers.

createArrays();–Call function once it is loaded, before the hook is added below.

function userJoin( ply, stid, unid )
if(staff[ply:SteamID()] ~ nil) { --If user has specified rank
rank, userServer = staff[ply:SteamID()]:match("([^,]+),([^,]+)")–Split Admin,TTT to “Admin” and “TTT”
if server == userServer or userServer == “*” then–If connecting to designated server, or is a global rank
ULib.ucl.addUser(ply:SteamID(), {}, {}, rank)–Sets to original rank, as he/she is designated server
local oldRank = ranks[rank];
local newRank = “Trusted”–Sets to lower rank, as he/she is designated server
for key, value in ranks do–Loops through all ranks. Gets highest rank that is lower than players max rank on designated server.
if(value < oldRank && value > ranks[newRank]) then
newRank = key;
ULib.ucl.addUser(ply:SteamID(), {}, {}, newRank)
hook.Add( “PlayerAuthed”, “playerauthed”, userJoin )–Add hook to “playerauthed”, called when a player is authed by Steam and receives a SteamID

I’m not asking for someone to write the script for me, I would just like some pointers. I have also commented the code so they it may be an easier read.

Thanks for any input, it’s really appreciated.


PS: On a side note, is THIS the best way to write to a local Garry’s Mod file?

It would not work to test it in singleplayer.

If you put ULX and run it with a multiple player, it can be tested.

go away nooky nobody likes you

(User was banned for this post ("Why reply/flaming" - NiandraLades))

Who the fuck are you?
Please come with revelant stuff instead of shitposting else fuck off.

So I can test in single player by just installing ULX?

No, there’s no way to test it in singleplayer. You could create a steampipe server to test it, or just have your friend upload it for a testing period.

Alright, thanks I’ll do that.

Chill out big dawg I’m friends with him. All is well