//@unloadnpc chanreg
//@loadnpc npc/classic/channels.txt


office,128,23,0	script	Channel Assistant	8W_SOLDIER,{
	
	OnSettings:
		mes .@npcname$;
		mes " Hello ^00CC00"+strcharinfo(PC_NAME)+"^000000!";
		mes "Sometimes it is very annoying to see so much information is displayed in your screen. I'm here to assist you with that.  Please select the announce information you wish to see.";
		while(1) {

			switch(select(
			 ((!#channel_system)?"- #system is [ ^ff0000Off^000000 ]:":"- #system is [ ^28bf00On^000000 ]:")+
			 ((!#channel_buying)?"- #buying is [ ^ff0000Off^000000 ]:":"- #buying is [ ^28bf00On^000000 ]:")+
			 ((!#channel_selling)?"- #selling is [ ^ff0000Off^000000 ]:":"- #selling is [ ^28bf00On^000000 ]:")+
			 ((!#channel_recruit)?"- #recruit is [ ^ff0000Off^000000 ]:":"- #recruit is [ ^28bf00On^000000 ]:")+
			 ((!#channel_battle)?"- #battle is [ ^ff0000Off^000000 ]:":"- #battle is [ ^28bf00On^000000 ]:")+
			 ((!#channel_event)?"- #event is [ ^ff0000Off^000000 ]:":"- #event is [ ^28bf00On^000000 ]:")+
	 		 "- ^777777Close^000000"
			)) {

		case 1:
			if (!#channel_system) { set #channel_system,1; atcommand "@join #system"; } else { set #channel_system,0; atcommand "@channel leave #system";} 
			break;
		case 2:
			if (!#channel_buying) { set #channel_buying,1; atcommand "@join #buying"; } else { set #channel_buying,0; atcommand "@channel leave #buying";}
			break;
		case 3:
			if (!#channel_selling) { set #channel_selling,1; atcommand "@join #selling"; } else { set #channel_selling,0; atcommand "@channel leave #selling";}
			break;
		case 4:
			if (!#channel_recruit) { set #channel_recruit,1; atcommand "@join #recruit"; } else { set #channel_recruit,0; atcommand "@channel leave #recruit";}
			break;
		case 5:
			if (!#channel_battle) { set #channel_battle,1; atcommand "@join #battle"; } else { set #channel_battle,0; atcommand "@channel leave #battle";}
			break;
		case 6:
			if (!#channel_event) { set #channel_event,1; atcommand "@join #event"; } else { set #channel_event,0; atcommand "@channel leave #event";}
			break;

		default:
			close;
		}
	}	

	//Onsystem:	if (!#channel_system) { set #channel_system,1; atcommand "@channel leave #system"; } else { set #channel_system,0; atcommand "@join #system";} end;
	//Onbuying:	if (!#channel_buying) { set #channel_buying,1; atcommand "@channel leave #buying"; } else { set #channel_buying,0; atcommand "@join #buying";} end;
	//Onselling:	if (!#channel_selling) { set #channel_selling,1; atcommand "@channel leave #selling"; } else { set #channel_selling,0; atcommand "@join #selling";} end;
	//Onrecruit:	if (!#channel_recruit) { set #channel_recruit,1; atcommand "@channel leave #recruit"; } else { set #channel_recruit,0; atcommand "@join #recruit";} end;
	//Onbattle:	if (!#channel_battle) { set #channel_battle,1; atcommand "@channel leave #battle"; } else { set #channel_battle,0; atcommand "@join #battle";} end;

	OnPCLoginEvent:
		if (!#channe2) {
			#channel_system = 1;
			#channel_buying = 1;
			#channel_selling = 1;
			#channel_recruit = 1;
			#channel_battle = 1;
			#channel_event = 1;
			#channel = 0;
			#channel2 = 1;


		}
		//localchannel
		if(#channel_system) { atcommand "@join #system";}
		if(#channel_buying) { atcommand "@join #buying";}
		if(#channel_selling) { atcommand "@join #selling";}
		if(#channel_recruit) { atcommand "@join #recruit";}
		if(#channel_battle) { atcommand "@join #battle";}
		if(#channel_event) { atcommand "@join #event";}
		end;

	OnInit:
		set .@npcname$,"Broadcast Assistant";
		//bindatcmd("system","broadcastsetting::Onsystem",0,99);
		//bindatcmd("buying","broadcastsetting::Onbuying",0,99);
		//bindatcmd("selling","broadcastsetting::Onselling",0,99);
		//bindatcmd("recruit","broadcastsetting::Onrecruit",0,99);
		//bindatcmd("battle","broadcastsetting::Onbattle",0,99);
		//bindatcmd("notice","broadcastsetting::OnSettings",0,99);
		end;

}
