/*
MP3+ v0.4
Copyright (C) 2005-2007 Ian (Juan) Cammarata
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see .
--------------------------------------------------------------------------------
http://ian.cammarata.us
*/
#include
#include
#define PRECACHE_COUNT 2
#define VERSION "0.4"
new inifile[100]
public plugin_init( )
{
register_plugin( "mp3+", VERSION, "Ian Cammarata" )
register_cvar( "mp3+_version", VERSION, FCVAR_SERVER )
register_concmd( "amx_mp3", "mp3", ADMIN_SLAY, " [mp3] - Play mp3 on all clients." )
return PLUGIN_CONTINUE
}
public plugin_precache( )
{
new varfile[100]
new len, text[100], pcfile[100]
//Make var folder if not exists
get_localinfo( "amxx_datadir", varfile, 99 )
format( varfile, 99, "%s/var", varfile )
if( !dir_exists( varfile ) ) mkdir( varfile )
get_localinfo( "amxx_configsdir", inifile, 99 )
format( inifile, 99, "%s/mp3precache.ini", inifile )
format( varfile, 99, "%s/mp3precache.var", varfile )
//Get name of last precached file
if( file_exists( varfile ) )
read_file( varfile, 0, pcfile, 99, len )
if( file_exists( inifile ) )
{
new inisize = file_size( inifile, 1 )
if( inisize )
{
new line = 0
if( strlen( pcfile ) )
while( !equal( pcfile, text ) && read_file( inifile, line, text, 99, len ) )
line++
new oldline = line
for( new i = 0; i <= PRECACHE_COUNT; i++)
{
if ( line == inisize ) line = 0
read_file( inifile, line, pcfile, 99, len )
write_file( varfile, pcfile, 0 )
format( pcfile, 99, "media/%s", pcfile )
precache_generic( pcfile )
line++
if( line == oldline ) break
}
}
}
return PLUGIN_CONTINUE
}
public mp3( id, level, cid )
{
if( !cmd_access( id, level, cid, 2 ) )
return PLUGIN_HANDLED
new cmd[4]
read_argv( 1, cmd, 4 )
if( equali( cmd, "stop") )
{
client_cmd( 0, "mp3 stop" )
client_print( 0, print_chat, "[AMX] MP3 : Stopped" )
}
if( equali( cmd, "list") )
{
show_motd( id, inifile, "MP3s" )
}
else
{
if( read_argc( ) != 3 )
client_print( id, print_console, "Usage: amx_mp3 [mp3]")
else
{
new title[32]
read_argv(2,title,32)
client_cmd(0,"mp3 %s media/%s",cmd,title)
strtoupper(cmd)
client_print(0,print_chat,"[AMX] : %s MP3 %s - To stop type, ^"mp3 stop^" in console.",cmd,title)
}
}
return PLUGIN_HANDLED
}