I have a deathrun server and i'm trying make it more special.
First, all players will be CT. Terrorist team is not available.
Every roundstart, a random CT player will be Terrorist.
How can i select a random CT player to change his team to T?
Scripts
Random T player in every round
Random T player in every round
1

addhook("roundstart","happynewyear")
function happynewyear()
	for lol=1,32 do
		parse("makect "..lol)
	end
	parse("maket "..math.random(1,32))
end
addhook("startround_prespawn","start")
function start()
	for i=1,#player(0,"table") do
		parse("makect "..i)
		max_players = #player(0,"table")
		random_player = math.random(1,max_players)
			if player(random_player,'exists') then
				parse("maket "..random_player)
			end
	end
end
Obviously Exactly Myself has writtenaddhook("roundstart","happynewyear")
function happynewyear()
	for lol=1,32 do
		parse("makect "..lol)
	end
	parse("maket "..math.random(1,32))
end
addhook("endround","_end")
function _end(mode)
local random = math.random(1,#player(0,'team2living'))
local team1 = player(0,'team1')
	for _,id in pairs(team1) do
		parse('makect '..id)
	end
	parse('maket '..random)
end
Suprise: Yours will fail at some point. Better:addhook("endround","rng")
function rng()
	for _, id in ipairs(player(0,"team1")) do
		parse("makect "..id)
	end
	local team2 = player(0,"team2")
	local c = math.random(1,#team2)
	parse("maket "..team2[c])
end
Cure Pikachu has written
Suprise: Yours will fail at some point. Better:addhook("endround","rng")
function rng()
	for _, id in ipairs(player(0,"team1")) do
		parse("makect "..id)
	end
	local team2 = player(0,"team2")
	local c = math.random(1,#team2)
	parse("maket "..team2[c])
end
1
