Parent Directory | Revision Log
Revision 1 -
(view)
(download)
Original Path: mp3.sma
1 : | ian | 1 | #include <amxmodx> |
2 : | #include <amxmisc> | ||
3 : | |||
4 : | #define PRECACHE_COUNT 2 | ||
5 : | |||
6 : | #define VERSION "0.4" | ||
7 : | |||
8 : | new inifile[100] | ||
9 : | |||
10 : | public plugin_init( ) | ||
11 : | { | ||
12 : | register_plugin( "mp3+", VERSION, "Ian Cammarata" ) | ||
13 : | register_cvar( "mp3+_version", VERSION, FCVAR_SERVER ) | ||
14 : | register_concmd( "amx_mp3", "mp3", ADMIN_SLAY, "<play|loop|stop|list> [mp3] - Play mp3 on all clients." ) | ||
15 : | return PLUGIN_CONTINUE | ||
16 : | } | ||
17 : | |||
18 : | public plugin_precache( ) | ||
19 : | { | ||
20 : | new varfile[100] | ||
21 : | new len, text[100], pcfile[100] | ||
22 : | |||
23 : | //Make var folder if not exists | ||
24 : | get_localinfo( "amxx_datadir", varfile, 99 ) | ||
25 : | format( varfile, 99, "%s/var", varfile ) | ||
26 : | if( !dir_exists( varfile ) ) mkdir( varfile ) | ||
27 : | |||
28 : | get_localinfo( "amxx_configsdir", inifile, 99 ) | ||
29 : | format( inifile, 99, "%s/mp3precache.ini", inifile ) | ||
30 : | format( varfile, 99, "%s/mp3precache.var", varfile ) | ||
31 : | |||
32 : | //Get name of last precached file | ||
33 : | if( file_exists( varfile ) ) | ||
34 : | read_file( varfile, 0, pcfile, 99, len ) | ||
35 : | |||
36 : | if( file_exists( inifile ) ) | ||
37 : | { | ||
38 : | new inisize = file_size( inifile, 1 ) | ||
39 : | if( inisize ) | ||
40 : | { | ||
41 : | new line = 0 | ||
42 : | if( strlen( pcfile ) ) | ||
43 : | while( !equal( pcfile, text ) && read_file( inifile, line, text, 99, len ) ) | ||
44 : | line++ | ||
45 : | |||
46 : | |||
47 : | new oldline = line | ||
48 : | |||
49 : | for( new i = 0; i <= PRECACHE_COUNT; i++) | ||
50 : | { | ||
51 : | if ( line == inisize ) line = 0 | ||
52 : | |||
53 : | read_file( inifile, line, pcfile, 99, len ) | ||
54 : | write_file( varfile, pcfile, 0 ) | ||
55 : | format( pcfile, 99, "media/%s", pcfile ) | ||
56 : | precache_generic( pcfile ) | ||
57 : | line++ | ||
58 : | if( line == oldline ) break | ||
59 : | } | ||
60 : | } | ||
61 : | } | ||
62 : | return PLUGIN_CONTINUE | ||
63 : | } | ||
64 : | |||
65 : | public mp3( id, level, cid ) | ||
66 : | { | ||
67 : | if( !cmd_access( id, level, cid, 2 ) ) | ||
68 : | return PLUGIN_HANDLED | ||
69 : | |||
70 : | new cmd[4] | ||
71 : | read_argv( 1, cmd, 4 ) | ||
72 : | if( equali( cmd, "stop") ) | ||
73 : | { | ||
74 : | client_cmd( 0, "mp3 stop" ) | ||
75 : | client_print( 0, print_chat, "[AMX] MP3 : Stopped" ) | ||
76 : | } | ||
77 : | if( equali( cmd, "list") ) | ||
78 : | { | ||
79 : | show_motd( id, inifile, "MP3s" ) | ||
80 : | } | ||
81 : | else | ||
82 : | { | ||
83 : | if( read_argc( ) != 3 ) | ||
84 : | client_print( id, print_console, "Usage: amx_mp3 <play|loop|stop> [mp3]") | ||
85 : | else | ||
86 : | { | ||
87 : | new title[32] | ||
88 : | read_argv(2,title,32) | ||
89 : | client_cmd(0,"mp3 %s media/%s",cmd,title) | ||
90 : | strtoupper(cmd) | ||
91 : | client_print(0,print_chat,"[AMX] : %s MP3 %s - To stop type, ^"mp3 stop^" in console.",cmd,title) | ||
92 : | } | ||
93 : | } | ||
94 : | return PLUGIN_HANDLED | ||
95 : | } |
Contact | ViewVC Help |
Powered by ViewVC 1.0.4 |