Trouble In Terrorist Town - ULX Respawn

I own my own Garry’s Mod 13 TTT server, and I seem to be running into the obvious problem of RDM. Again, I know this is going to happen, but it pisses me off a little. I’m looking for a ULX command to respawn people.
Actually, I have one for Garry’s Mod 12:


function ulx.cc_respawn( ply, command, argv, args )
	if #argv < 1 then
		ULib.tsay( ply, ulx.LOW_ARGS, true )
		return
	end

	local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
	if not targets then
		ULib.tsay( ply, err, true )
		return
	end

	for _, v in ipairs( targets ) do
		ulx.logUserAct( ply, v, "#A respawned #T" )
		v:SpawnForRound(true)
	end
end
ulx.concommand( "respawn", ulx.cc_respawn, "<user(s)> - Respawns target(s).", ULib.ACCESS_ADMIN, "!respawn", _, ulx.ID_PLAYER_HELP )
ulx.addToMenu( ulx.ID_MCLIENT, "Respawn", "ulx respawn" )

It would be great if this code was compatible with Garry’s Mod 13, but of course it’s not. Could anyone help me out?

NOTE: I did not create this code. I used Google, found this, didn’t work; looked for a GMod 13 one, couldn’t find one. I know the location of it is garrysmod\addons\ulx\lua\ulx\modules\sh then make a new lua called TTT or something of the sort and BAM I have a new ULX section of commands.

EDIT:
These are less important, but I also have a force traitor, detective, and innocent commands. They all cause errors in the same way as the respawn commands. If you feel so inclined…


function ulx.cc_traitor( ply, command, argv, args )
	if #argv < 1 then
		ULib.tsay( ply, ulx.LOW_ARGS, true )
		return
	end

	local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
	if not targets then
		ULib.tsay( ply, err, true )
		return
	end

	for _, v in ipairs( targets ) do
		ulx.logUserAct( ply, v, "#A turned #T into a traitor" )
		v:SetRole(ROLE_TRAITOR)
		SendFullStateUpdate()
	end
end
ulx.concommand( "traitor", ulx.cc_traitor, "<user(s)> - Turns target(s) into traitors.", ULib.ACCESS_ADMIN, "!traitor", _, ulx.ID_PLAYER_HELP )
ulx.addToMenu( ulx.ID_MCLIENT, "Traitor", "ulx traitor" )

function ulx.cc_detective( ply, command, argv, args )
	if #argv < 1 then
		ULib.tsay( ply, ulx.LOW_ARGS, true )
		return
	end

	local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
	if not targets then
		ULib.tsay( ply, err, true )
		return
	end

	for _, v in ipairs( targets ) do
		ulx.logUserAct( ply, v, "#A turned #T into a detective" )
		v:SetRole(ROLE_DETECTIVE)
		SendFullStateUpdate()
	end
end
ulx.concommand( "detective", ulx.cc_detective, "<user(s)> - Turns target(s) into detectives.", ULib.ACCESS_ADMIN, "!detective", _, ulx.ID_PLAYER_HELP )
ulx.addToMenu( ulx.ID_MCLIENT, "Detective", "ulx detective" )

function ulx.cc_innocent( ply, command, argv, args )
	if #argv < 1 then
		ULib.tsay( ply, ulx.LOW_ARGS, true )
		return
	end

	local targets, err = ULib.getUsers( argv[ 1 ], _, true, ply ) -- Enable keywords
	if not targets then
		ULib.tsay( ply, err, true )
		return
	end

	for _, v in ipairs( targets ) do
		ulx.logUserAct( ply, v, "#A turned #T into an innocent" )
		v:SetRole(ROLE_INNOCENT)
		SendFullStateUpdate()
	end
end
ulx.concommand( "innocent", ulx.cc_innocent, "<user(s)> - Turns target(s) into innocents.", ULib.ACCESS_ADMIN, "!innocent", _, ulx.ID_PLAYER_HELP )
ulx.addToMenu( ulx.ID_MCLIENT, "Innocent", "ulx innocent" )

EDIT2: I also posted this in the “What do you need help with” thread. I just noticed it.

Respawn

Traitor

As for detective and innocent, just change all the traitors in the traitors command to either detective or innocent

Thank you very much. The code works perfectly. I really appreciate it.

Sorry to bump this, but ziev, can you explain how this code works? The only command I see on the TTT website to change role to traitor is ttt_force_traitor, but you seem to be calling SetRole. If you explained this and commented what it does on every line I would REALLY appreciate it!

I just based the codes off of pre-existing ulx command codes (I know very little lua at all) and then the community helped me fix any errors with them. So that’s how I did

Where could I find a reference for these command codes?

If you’re talking about the “pre-existing ulx codes” I referenced, I just went into the ulx folder on my server and looked at the lua files in there

Ok. Thanks.

Thanks

Terribly sorry for bumping. Was wondering as to where to drop this lovely lua?

What .lua files are these in? Please reply, Thanks!