/*
Fordította: BBk - Death of Legend
*/
#include <amxmodx>
#include <amxmisc>
#if !defined charsmax
#define charsmax(%1) sizeof(%1)-1
#endif
#define MAX_MEDIA 30
new g_mediaID
new g_media_player[1536]
new g_media_names[MAX_MEDIA][32]
new g_media_urls[MAX_MEDIA][512]
new g_menuposition[33]
new g_currentmediaplaying[33]
enum INFO { NAME, AUTHOR, VERSION }
new const PLUGIN[INFO:3][] =
{
"Adv. Media Player", "cheap_suit", "3.1"
}
public plugin_init()
{
register_plugin(PLUGIN[NAME],PLUGIN[VERSION],"cheap_suit")
register_cvar(PLUGIN[NAME], PLUGIN[VERSION], FCVAR_SPONLY|FCVAR_SERVER)
register_menucmd(register_menuid("media_list"), 1023, "action_medialist")
register_clcmd("say", "cmd_say")
register_clcmd("say_team", "cmd_say")
register_concmd("amx_addmedia", "cmd_addmedia", ADMIN_CFG, "-
utmutato: <media name> <media url> | Figyelem! Pontosan irja be!")
register_concmd("amx_setmedia", "cmd_setmedia", ADMIN_BAN, "-
utmutato: <@all|playerID> <media ID> | beallitott media lejatszo(k)")
register_concmd("amx_reloadmedia", "cmd_reloadmedia", ADMIN_CFG, "- az
amp_medialist.ini fajl ujratoltes")
register_concmd("amx_listmedia", "cmd_listmedia", 0, "- az
adminok szamara mutassa az osszes elerheto zeneszamot")
register_concmd("amx_listeners", "cmd_showlisteners", 0, "-
megjeleniti az aktualis media lejatszot")
initialize()
}
public client_putinserver(id)
{
g_currentmediaplaying[id] = -1
set_task(20.0, "task_inform", id)
}
public task_inform(id) if(is_user_connected(id))
client_print(id, print_chat, "* A szerveren %s fut. Tracklista megtekintesehez,
lejatszasahoz ird be: /listen | /music | /media", PLUGIN[NAME])
public task_info(id) if(is_user_connected(id))
client_print(id, print_chat, "* Most a %s szol. A zene leallitasahoz ird be: /stop",
g_media_names[g_currentmediaplaying[id]])
public cmd_reloadmedia(id, level, cid)
{
if(!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED_MAIN
initialize()
console_print(id, "* Az amp_medialist.ini fajl ujratoltve.")
return PLUGIN_HANDLED_MAIN
}
public cmd_listmedia(id)
{
console_print(id, "* Elerheto Media:")
for(new i = 0; i < g_mediaID; i++)
console_print(id, "#%d %s", i, g_media_names[i])
return PLUGIN_HANDLED_MAIN
}
public cmd_showlisteners(id)
{
console_print(id, "* Jelenleg ezt a szamot hallod:")
new players[32], num, i, index, mediaid
get_players(players, num, "hc")
for(i = 0; i < num; i++)
{
index = players[i]
mediaid = g_currentmediaplaying[index]
if(mediaid == -1)
continue
static name[32]
get_user_name(index, name, charsmax(name))
console_print(id, "%s #%d. %s", name, mediaid, g_media_names[mediaid])
}
return PLUGIN_HANDLED_MAIN
}
public cmd_addmedia(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED_MAIN
new medianame[32], mediaurl[256]
read_argv(1, medianame, charsmax(medianame))
read_argv(2, mediaurl, charsmax(mediaurl))
copy(g_media_names[g_mediaID], charsmax(g_media_names[]), medianame)
copy(g_media_urls[g_mediaID++], charsmax(g_media_urls[]), mediaurl)
new configs_dir[128], file[128]
get_localinfo("amxx_configsdir", configs_dir, charsmax(configs_dir))
formatex(file, charsmax(file), "%s/%s", configs_dir, "amp_medialist.ini")
if(file_exists(file))
{
new text[512]
formatex(text, charsmax(text), "^n^"%s^" ^"%s^"", medianame, mediaurl)
write_file(file, text)
console_print(id, "* Hozzaadva %s az amp_medialist.ini-hez.", medianame)
}
return PLUGIN_HANDLED_MAIN
}
public cmd_setmedia(id, level, cid)
{
if(!cmd_access(id, level, cid, 3))
return PLUGIN_HANDLED_MAIN
new player[32], medianumber[11]
read_argv(1, player, charsmax(player))
read_argv(2, medianumber, charsmax(medianumber))
new mediaid = str_to_num(medianumber)
if(mediaid > g_mediaID)
{
console_print(id, "* Nem talalhato hangfajl.")
return PLUGIN_HANDLED_MAIN
}
if(equali(player, "@all"))
{
new players[32], num, i
get_players(players, num, "hc")
for(i = 0; i < num; i++)
play_media(players[i], mediaid)
}
else
{
new index = cmd_target(id, player, 2)
if(index)
{
new name[32]
get_user_name(index, name, charsmax(name))
play_media(index, mediaid)
client_print(id, print_console, "* A %s szol a %s -tol.",
g_media_names[mediaid], name)
}
}
return PLUGIN_HANDLED_MAIN
}
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,
"/playmedia") || equali(say_args, "/listen"))
{
display_medialist(id, g_menuposition[id] = 0)
return PLUGIN_HANDLED_MAIN
}
else if(equali(say_args, "/stopmusic") || equali(say_args, "/stop") || equali(say_args,
"/stopmedia"))
{
g_currentmediaplaying[id] = -1
static motd[1024], len
len = formatex(motd, charsmax(motd), "<html><head><style
type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</s
tyle></head><pre><body>")
len += formatex(motd[len], charsmax(motd) - len, "<center>Zene leallitva. Ezt
hozta neked: %s.^n", PLUGIN[NAME])
len += formatex(motd[len], charsmax(motd) - len, "<center>Ez a plugin az
amxmodx.org-rol szarmazik.^n")
len += formatex(motd[len], charsmax(motd) - len, "</body></pre></html>^n")
show_motd(id, motd, PLUGIN[NAME])
return PLUGIN_HANDLED_MAIN
}
else if(equali(say_args, "/playagain") || equali(say_args, "/reload") ||
equali(say_args, "/replay"))
{
if(g_currentmediaplaying[id] == -1)
client_print(id, print_chat, "* Nehany hangfaljt On nem hallhat.")
else
play_media(id, g_currentmediaplaying[id])
return PLUGIN_HANDLED_MAIN
}
return PLUGIN_CONTINUE
}
display_medialist(id, pos)
{
if(pos < 0)
return
new maxtotal = g_mediaID
new start = pos * 8
if(start >= maxtotal)
start = pos = g_menuposition[id]
new menubody[512]
new len = format(menubody, charsmax(menubody), "Valasszon egy szamot:^n^n")
new end = start + 8
new keys = MENU_KEY_0
if(end > maxtotal)
end = maxtotal
new b = 0
for(new a = start; a < end; ++a)
{
keys |= (1<<b)
len += formatex(menubody[len], charsmax(menubody), "%d. %s^n", ++b,
g_media_names[a])
}
if(end != maxtotal)
{
formatex(menubody[len], charsmax(menubody), "^n9. %s...^n0. %s", "Tobb", pos ?
"Vissza" : "Kilepes")
keys |= MENU_KEY_9
}
else
formatex(menubody[len], charsmax(menubody), "^n0. %s", pos ? "Vissza" :
"Kilepes")
show_menu(id, keys, menubody, -1, "media_list")
}
public action_medialist(id, key)
{
switch(key)
{
case 8: display_medialist(id, ++g_menuposition[id])
case 9: display_medialist(id, --g_menuposition[id])
default:play_media(id, (g_menuposition[id] * 8 + key))
}
return PLUGIN_HANDLED
}
play_media(id, media_id)
{
if(!file_exists(g_media_player))
return
g_currentmediaplaying[id] = media_id
new player[sizeof(g_media_player)], motd[sizeof(g_media_player)], line, length
while(read_file(g_media_player, line++, player, charsmax(player), length))
add(motd, charsmax(motd), player)
replace_all(motd, charsmax(motd), "[MEDIA_NAME]", g_media_names[media_id])
replace_all(motd, charsmax(motd), "[MEDIA_URL]", g_media_urls[media_id])
show_motd(id, motd, PLUGIN[NAME])
set_task(5.0, "task_info", id)
}
initialize()
{
new configs_dir[128], file[128], file_text[2048], len = 0; g_mediaID = 0
get_localinfo("amxx_configsdir", configs_dir, charsmax(configs_dir))
formatex(file, charsmax(file), "%s/%s", configs_dir, "amp_medialist.ini")
if(!file_exists(file))
{
len = format(file_text, charsmax(file_text), "; %s Media Lista^n", PLUGIN[NAME])
len += format(file_text[len], charsmax(file_text) - len, "; Formatum: ^"Hang
Neve^" ^"Hang URL^"^n")
len += format(file_text[len], charsmax(file_text) - len, "; eg. ^"Papa Roach -
Last Resort^" ^"http://www.mysite.com/lastresort.mp3^n^"")
write_file(file, file_text)
}
formatex(g_media_player, charsmax(g_media_player), "%s/%s", configs_dir,
"amp_player.html"); len = 0
if(!file_exists(g_media_player))
{
len = formatex(file_text, charsmax(file_text), "<html><head><style
type=^"text/css^">pre{color:#FFB000;}body{background:#000000;margin-left:8px;margin-top:0px;}</s
tyle></head><pre><body>")
len += formatex(file_text[len], charsmax(file_text) - len,
"<center><b>Hang:</b>[MEDIA_NAME]^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<center>Uzenet: A
zeneszam betoltese hosszu ideig eltarthat.^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<center>Bezarhatod a
MOTD-t, a zene folyamatosan szolni fog.^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<center><OBJECT
ID=^"MediaPlayer1^" width=400 height=144^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"classid=^"CLSID:22D6F312-B0F6-11D0-94AB-0080C74C7E95^"^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"CODEBASE=^"http://activex.microsoft.com/activex/controls/mplayer/en/nsmp2inf.cab#Version=6,4,5,
715^"^n")
len += formatex(file_text[len], charsmax(file_text) - len, "standby=^"Microsoft®
Windows® Media Player componensek betoltese...^"^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"type=^"application/x-oleobject^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<PARAM
NAME=^"AutoStart^" ERTEK=^"Igaz^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<PARAM
NAME=^"FileName^" ERTEK=^"[MEDIA_URL]^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<PARAM
NAME=^"ShowControls^" ERTEK=^"Igaz^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<PARAM
NAME=^"ShowStatusBar^" ERTEK=^"Hamis^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<PARAM
NAME=^"AutoRewind^" ERTEK=^"Igaz^">^n")
len += formatex(file_text[len], charsmax(file_text) - len, "<EMBED
type=^"application/x-mplayer2^"
pluginspage=^"http://www.microsoft.com/Windows/MediaPlayer/^"^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"SRC=^"[MEDIA_URL]^"^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"name=^"MediaPlayer1^"^n")
len += formatex(file_text[len], charsmax(file_text) - len, "autostart=1^n")
len += formatex(file_text[len], charsmax(file_text) - len, "showcontrols=1^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"autorewind=^"Igaz^"^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"showstatusbar=^"Hamis^">^n")
len += formatex(file_text[len], charsmax(file_text) - len,
"</EMBED></OBJECT></body></pre></html>^n")
write_file(g_media_player, file_text)
}
new text[1024], line, length
while(read_file(file, line++, text, charsmax(text), length))
{
trim(text)
if(!length || text[0] == ';')
continue
if(g_mediaID >= MAX_MEDIA)
break
static left[32], right[512]
strbreak(text, left, charsmax(left), right, charsmax(right))
replace_all(left, charsmax(left), "^"", "")
replace_all(right, charsmax(right), "^"", "")
replace_all(right, charsmax(right), " ", "%20")
copy(g_media_names[g_mediaID], charsmax(g_media_names[]), left)
copy(g_media_urls[g_mediaID++], charsmax(g_media_urls[]), right)
}
}