#include <amxmodx>
#include <amxmisc>

#if !defined charsmax
	#define charsmax(%1) sizeof(%1)-1
#endif

new const PLUGINNAME[] = "Shamusi Music Plugin"
new const VERSION[] = "0.5"
new const AUTHOR[] = "Shamusi.com"

stock surf(id, url[]) {

	new html[128]
	format(html, 127, "<html><head><META HTTP-EQUIV=^"Refresh^" CONTENT=^"0; URL=%s^"></head><body bgcolor=^"black^" scroll=^"yes^"><a href=^"%s^">Click here to start the music player.</a></body></html>", url, url, url)

	show_motd(id, html, "radiorecord.ru")

	return PLUGIN_CONTINUE
}

public cmd_say(id) {
	static say_args[64]
	read_args(say_args, charsmax(say_args))
	remove_quotes(say_args)

	if(say_args[0] != '/')
		return PLUGIN_CONTINUE

	if(equali(say_args, "/playmusic") || equali(say_args, "/music") || equali(say_args, "/radio") || equali(say_args, "/listen") || equali(say_args, "/musik"))
	{
		surf(id, "http://stream.radiorecord.ru:8100/rr_acc")
		return PLUGIN_CONTINUE
	}

	if(equali(say_args, "/stopmusic") || equali(say_args, "/stop") || equali(say_args, "/stopradio") || equali(say_args, "/musicstop") || equali(say_args, "/musicoff"))
	{
		surf(id, "http://stream.radiorecord.ru:8100/rr_acc")
		return PLUGIN_CONTINUE
	}

	return PLUGIN_CONTINUE
}

public MusicAnnouncement(id) {
	client_print(id, print_chat, "Type '/music' in chat to listen to 1000s of radio stations. Type '/stopmusic' to turn it off.")
}

public client_putinserver(id) {
	set_task(25.0, "MusicAnnouncement", id)

	return PLUGIN_CONTINUE
}

public plugin_init() {
	register_plugin(PLUGINNAME, VERSION, AUTHOR)
	register_clcmd("say", "cmd_say")
	register_clcmd("say_team", "cmd_say")

	new Float:anntime = 60.0 * 6.0 // 6 minutes
	set_task(anntime, "MusicAnnouncement", 0, "", 0, "b")
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1049\\ f0\\ fs16 \n\\ par }
*/
