I need help for my new Script:
Because I want to have if only 1 Player is alive the round will be restart. But I tried soo muuuch things and nothink works :(.
Can anyone help me?
Scripts
How can I restart round if only 1 Enemy is left?
How can I restart round if only 1 Enemy is left?
1

addhook("die", "checkAlive")
addhook("leave", "checkAlive")
function checkAlive()
	count = #player(0,"team1living") + #player(0,"team2living");
	if (count == 1) do
		parse("sv_restartround 0")
	end
end
count = #player(0,"tableliving")
addhook("die", "checkAlive")
addhook("leave", "checkAlive")
function checkAlive()
	count = #player(0,"tableliving")
	for id=1,32-count do
		if kill[id]==3 then
			spec[id]=0
			kill[id]=0
			if count == 1 then
				parse("restart")
			end
		end
	end
end
addhook("die", "checkAlive")
addhook("leave", "checkAlive")
function checkAlive()
count = #player(0,"tableliving")
	local ii = 32 - count
for id=1,ii do
if kill[id]==3 then
spec[id]=0
kill[id]=0
if count == 1 then
parse("restart")
end
end
end
end
. addhook("die", "RestartRoundOnDie")
function RestartRoundOnDie()
	if #player(0, "tableliving") == 1 then parse("restart") end
end
addhook("ms100", "checkAlive")
function checkAlive()
	count = #player(0,"tableliving")
	if kill[id]==3 then
		spec[id]=0
		kill[id]=0
	end
	if count == 1 then
		msg("penis")
	end
end
Banaan has writtenaddhook("die", "RestartRoundOnDie")
function RestartRoundOnDie()
	if #player(0, "tableliving") == 1 then parse("restart") end
end
addhook("die", "die")
function die()
count=#player(0,"team1")+#player(0,"team2")
if count== 1 then
	for i = 1,32 do
	if player(i,"exists") and player(i,"team")==0 then
	if math.random(1,2)==1 then --every spectator gets a random team
		parse("maket "..i)
	else
		parse("makect "..i)
	end
	 parse("restart") --instead of restart i would reset other stuff like it was before starting the game
	
end
end

addhook("die", "RestartRoundOnDie")
addhook("join", "ResetDeaths")
addhook("leave", "WasILiving")
addhook("startround", "ResetDeaths")
local d = {}
function ResetDeaths(id) d[id] = 0 end
function WasILiving(id)
	if #player(0, "tableliving") == 1 then
		for _, p in pairs(player(0, "table")) do
			if d[p] ~= 3 then return 0 end
		end
		parse("restart")
	end
end
function RestartRoundOnDie(id)
	d[id] = d[id] + 1
	if d[id] == 3 then
		if #player(0, "tableliving") == 1 then
			for _, p in pairs(player(0, "table")) do
				if d[p] ~= 3 then return 0 end
			end
			parse("restart")
		end
	end
end
But there is no Error or something like that.
addhook("die", "RestartRoundOnDie")
addhook("join", "ResetDeaths")
addhook("leave", "WasILiving")
addhook("startround", "ResetAllDeaths")
local d = {}
function ResetDeaths(id) d[id] = 0 end
function ResetAllDeaths() for _, p in pairs(player(0, "table")) do d[p] = 0 end end
function WasILiving(id)
	if #player(0, "tableliving") == 1 then
		for _, p in pairs(player(0, "table")) do
			if d[p] ~= 3 then return 0 end
		end
		parse("restart")
	end
end
function RestartRoundOnDie(id)
	d[id] = d[id] + 1
	if d[id] == 3 then
		if #player(0, "tableliving") == 1 then
			for _, p in pairs(player(0, "table")) do
				if not player(p, "exists") and d[p] ~= 3 then return 0 end
			end
			parse("restart")
		end
	end
end
It works!
1
