
main()
{
	level endon("ex_gameover");
	level notify("ex_serverinfo");
	level endon("ex_serverinfo");

	level serverInfoGT();
	level serverInfoExtreme();
}

serverInfoGT()
{
	// time limit
	checkCvar("ui_timelimit", level.timelimit);

	// score limit
	checkCvar("ui_scorelimit", level.scorelimit);

	if(level.ex_roundbased)
	{
		// round limit
		checkCvar("ui_gtinfo_a", level.roundlimit);		

		// round length
		checkCvar("ui_gtinfo_b", level.roundlength);

		// grace period
		checkCvar("ui_gtinfo_c", level.graceperiod);

		// bomb timer?
		if(level.ex_currentgt == "sd")
			checkCvar("ui_gtinfo_d", level.bombtimer);
	}
	else if(level.ex_currentgt == "htf")
	{
		// flag hold time
		checkCvar("ui_gtinfo_a", level.holdtime);

		// flag recover time
		checkCvar("ui_gtinfo_b", level.flagrecovertime);

		// flag spawn delay
		checkCvar("ui_gtinfo_c", level.flagspawndelay);
	}
	else if(level.ex_currentgt == "ihtf")
	{
		// flag hold time
		checkCvar("ui_gtinfo_a", level.HoldTimeToScore);

		// flag recover time
		checkCvar("ui_gtinfo_b", level.PointsForHoldingFlag);

		// flag spawn delay
		checkCvar("ui_gtinfo_c", level.flagspawndelay);
	}

	// player spawn delay?
	if(level.ex_currentgt == "ctf" || level.ex_currentgt == "htf" || level.ex_currentgt == "ihtf")
		checkCvar("ui_gtinfo_d", level.respawndelay);
}

serverInfoExtreme()
{
	// rank system
	if(!level.ex_ranksystem) rank = 0;
		else rank = level.ex_rank_wmdtype + 1;
	checkCvar("ui_rank", rank);

	// weapon class
	checkCvar("ui_weapon_only", level.ex_wepo_class);
	
	// secondary weapons
	secwep = 0;
	if(level.ex_wepo_secondary) secwep = 1;
	if(level.ex_wepo_secondary && level.ex_wepo_sec_enemy) secwep = 2;
	checkCvar("ui_secondarywep", secwep);

	// enemy weapons
	checkCvar("ui_enemywep", level.ex_wepo_enemy);

	// damage modifier
	checkCvar("ui_damagemod", level.ex_wdmodon);

	// grenades
	//  0 = none
	//  1 = frag nades
	//  2 = smoke nades
	//  4 = fire nades
	//  8 = gas nades
	// 16 = satchel charges
	frags = 0;
	if(level.ex_wepo_allow_frag)
	{
		if(level.ex_firenades) frags = 4;
			else if(level.ex_gasnades) frags = 8;
				else if(level.ex_satchelcharges) frags = 16;
					else frags = 1;
	}
	smokes = 0;
	if(level.ex_wepo_allow_smoke)
	{
		if(level.ex_smoke["american"] == 7) smokes = 4;
			else if(level.ex_smoke["american"] == 8) smokes = 8;
				else if(level.ex_smoke["american"] == 9) smokes = 16;
				  else smokes = 2;
	}
	nades = (frags | smokes);
	checkCvar("ui_nades", nades);

	// tripwires
	checkCvar("ui_tripwire", level.ex_tweapon);

	// landmines
	checkCvar("ui_landmines", level.ex_landmines);

	// spawn protection
	spro = 0;
	if(level.ex_spwn_time >= 1)
	{
		if(level.ex_spwn_invisible) spro = 2;
			else spro = 1;
	}
	checkCvar("ui_spawnpro", spro);

	// health system
	checkCvar("ui_healthsystem", level.ex_healthbar);

	// firstaid system
	checkCvar("ui_firstaid", level.ex_callformedic);

	// sprinting
	if(level.ex_sprint >= 1) sprint = 1;
		else sprint = 0;
	checkCvar("ui_sprinting", sprint);

	// forced autoassign
	checkCvar("ui_forced_auto", level.ex_forceauto);
}

checkCvar(definition, setting)
{
	if(!isDefined(definition) || !isDefined(setting)) return;

	// check if makeCvarServerInfo has already been created
	if(getCvar(definition) == "") makeCvarServerInfo(definition, setting);

	// if the value has changed, update the cvar
	if(getCvarInt(definition) != setting) setCvar(definition, setting);
}
