I'd like for someone to write a script which swaps teams after each round. For example if the player is a CT than after round he would be T. I would use it my server, as well it would help me learn about lua more.
Thanks!
Scripts
Lua request
Lua request
1

addhook("startround_prespawn", "swapteams")
function swapteams(mode)
	local playerlist=player(0,"table")
	for _,id in pairs(playerlist) do
		if (player(id, "team") == 1) then
			parse("makect "..id)
		elseif (player(id, "team") == 2) then
			parse("maket "..id)			
		end
	end
end
addhook("endround","_endround")
function _endround(m)
local playerlist=player(0,"table")
for _,id in pairs(playerlist) do
if player(id, "team") == 1 then
parse("makect "..id)
elseif player(id, "team") == 2 then
parse("maket "..id)
end
end
end
Alpha Beta's code will be better since it doesn't kill the surviving players.
Alpha Beta has writtenaddhook("startround_prespawn", "swapteams")
function swapteams(mode)
	local playerlist=player(0,"table")
	for _,id in pairs(playerlist) do
		if (player(id, "team") == 1) then
			parse("makect "..id)
		elseif (player(id, "team") == 2) then
			parse("maket "..id)			
		end
	end
end
Zeik, Thanks!
useigor addhook("endround","_endround")
function _endround(m)
local playerlist=player(0,"table")
	if(m ~= 4 and m ~= 3) then
		for _,id in pairs(playerlist) do
			if player(id, "team") == 1 then
				parse("makect "..id)
			elseif player(id, "team") == 2 then
				parse("maket "..id)
			end
		end
	end
end
1
