TTT Post-Round Deathmatch Lua script help

Hey guys!

I’m hoping at least one of you lovely people can help me with a script.

I was wondering how I could make a script where it would respawn all players after a round ends for post-round deathmatch. Then, if possible, respawn all players again every 5 seconds or so.

If you don’t wanna do the whole script, just point me in the right direction please.

Many thanks!

[editline]20th January 2016[/editline]

I have this so far; I don’t know if it will work though. I’m quite new to creating new scripts, but I’m trying to learn haha.



if (SERVER) then
	AddCSLuaFile()
	
	local roundEnd = hook.Call("TTTEndRound")
	
	if roundEnd == WIN_INNOCENT or WIN_TRAITOR or WIN_TIMELIMIT then
		RunConsoleCommand("ulx", "respawn", "*")
	end
end


I don’t know how to make this type of script, but I know there is a good TTT deathmatch script somewhere that enables dead people to deathmatch while the round is still in progress (and the alive people can’t see or hear them).

Anyway, first direction I want to point you in: Don’t rely on ULX to respawn your players.
Instead, make your own proper code for it. I think something like this should do it:


for k, ply in pairs( player.GetAll() ) do
    if IsValid(ply) and !ply:Alive() then
        ply:Spawn()
    end
end

I’m no lua master myself, but I think that’s how you would respawn all dead players.

That deathmatch script is buggy and npc’s will still attack the people in the deathmatch I would not reccomend it. CAC also states there is an exploit in the script.

Yea not even this edited version worked.

Funny thing about it though. When I edited it and saved it, the server spewed out the csay command, but I don’t think it respawned everyone.



if (SERVER) then
	AddCSLuaFile()
	
	local roundEnd = hook.Call("TTTEndRound")
	
	if roundEnd == WIN_INNOCENT or WIN_TRAITOR or WIN_TIMELIMIT then
		for k, ply in pairs( player.GetAll() ) do
			if IsValid(ply) and !ply:Alive() then
				ply:Spawn()
			end
		end
		RunConsoleCommand("ulx", "csay", "It's post-round deathmatch time!")
    end
end


I also have the SpecDM addon installed on my server. What I’m aiming for is the POST-round deathmatch.

Bump because I need help. lmao

Okay, so now I have this.



if (SERVER) then
	AddCSLuaFile()


	hook.Add("TTTEndRound", "PostRoundDeathmatchRespawner", function(win)
		if win == WIN_INNOCENT or WIN_TRAITOR or WIN_TIMELIMIT then
			for k, ply in pairs( player.GetAll() ) do
				if IsValid(ply) and !ply:Alive() then
					ply:Spawn()
				end
			end
			RunConsoleCommand("ulx", "csay", "It's post-round deathmatch time!")
		end
	end )

end


Still not working. Any help?



	hook.Add("TTTEndRound", "PostRoundDeathmatchRespawner", function()
			for k, ply in pairs( player.GetAll() ) do
				if IsValid(ply) and !ply:Alive() then
					ply:Spawn()
				end
			end
			RunConsoleCommand("ulx", "csay", "It's post-round deathmatch time!")
	end )


The hook doesn’t return any parameters. And why are you checking for every win type anyways when you could’ve just left that whole bit out since it was always going to be true.

I really didn’t even know where to start when I started trying to put together this script. I’m a newbie, if you wanna call me that haha. Thank you for your help, but one question. This would all go inside the if (SERVER) right?

EDIT: This page says different about the parameters thing. http://ttt.badking.net/guides/hooks

[editline]22nd January 2016[/editline]

This is the code that finally decided to work, if anyone wants to use it feel free.

Code removed. Don’t put it anywhere near your server because it caused crashes for mine.