lockteam_minlvl = 10

lockteams_menu = CreateMenu("Lock/Unlock change team", "Spectator,Terrorist,Counter-Terrorist")
team_locked = {}

function lockteams_menu:getcustombutton(b,id,def)
	if def then
		if team_locked[b-1] then
			return def.."|Locked"
		end
		return def.."|Unlocked"
	end
end

function lockteams_menu:click(id,b,p)
	if b > 0 then
		if team_locked[b-1] then
			team_locked[b-1] = nil
		else
			team_locked[b-1] = true
		end
		lockteams_menu:OpenPlayer(id, p)
	end
end

addhook("team","lockteam_switchteam")
function lockteam_switchteam(id,t)
	if team_locked[t] and SERVER_RANK[USER[id]["rank"]].lvl < lockteam_minlvl then
		ErrorMSG(id, "This team has been locked by administrator")
		return 1
	end
end

AddMenu(lockteams_menu, 30)