[Half-Life AMXX] / mp3_plus.sma Repository:
ViewVC logotype

Annotation of /mp3_plus.sma

Parent Directory Parent Directory | Revision Log Revision Log


Revision 25 - (view) (download)
Original Path: mp3.sma

1 : ian 25 /*
2 :     MP3+ v0.4
3 :     Copyright (C) 2005-2007 Ian (Juan) Cammarata
4 :    
5 :     This program is free software: you can redistribute it and/or modify
6 :     it under the terms of the GNU Affero General Public License as
7 :     published by the Free Software Foundation, either version 3 of the
8 :     License, or (at your option) any later version.
9 :    
10 :     This program is distributed in the hope that it will be useful,
11 :     but WITHOUT ANY WARRANTY; without even the implied warranty of
12 :     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 :     GNU Affero General Public License for more details.
14 :    
15 :     You should have received a copy of the GNU Affero General Public License
16 :     along with this program. If not, see <http://www.gnu.org/licenses/>.
17 :     --------------------------------------------------------------------------------
18 :     http://ian.cammarata.us
19 :     */
20 :    
21 : ian 1 #include <amxmodx>
22 :     #include <amxmisc>
23 :    
24 :     #define PRECACHE_COUNT 2
25 :    
26 :     #define VERSION "0.4"
27 :    
28 :     new inifile[100]
29 :    
30 :     public plugin_init( )
31 :     {
32 :     register_plugin( "mp3+", VERSION, "Ian Cammarata" )
33 :     register_cvar( "mp3+_version", VERSION, FCVAR_SERVER )
34 :     register_concmd( "amx_mp3", "mp3", ADMIN_SLAY, "<play|loop|stop|list> [mp3] - Play mp3 on all clients." )
35 :     return PLUGIN_CONTINUE
36 :     }
37 :    
38 :     public plugin_precache( )
39 :     {
40 :     new varfile[100]
41 :     new len, text[100], pcfile[100]
42 :    
43 :     //Make var folder if not exists
44 :     get_localinfo( "amxx_datadir", varfile, 99 )
45 :     format( varfile, 99, "%s/var", varfile )
46 :     if( !dir_exists( varfile ) ) mkdir( varfile )
47 :    
48 :     get_localinfo( "amxx_configsdir", inifile, 99 )
49 :     format( inifile, 99, "%s/mp3precache.ini", inifile )
50 :     format( varfile, 99, "%s/mp3precache.var", varfile )
51 :    
52 :     //Get name of last precached file
53 :     if( file_exists( varfile ) )
54 :     read_file( varfile, 0, pcfile, 99, len )
55 :    
56 :     if( file_exists( inifile ) )
57 :     {
58 :     new inisize = file_size( inifile, 1 )
59 :     if( inisize )
60 :     {
61 :     new line = 0
62 :     if( strlen( pcfile ) )
63 :     while( !equal( pcfile, text ) && read_file( inifile, line, text, 99, len ) )
64 :     line++
65 :    
66 :    
67 :     new oldline = line
68 :    
69 :     for( new i = 0; i <= PRECACHE_COUNT; i++)
70 :     {
71 :     if ( line == inisize ) line = 0
72 :    
73 :     read_file( inifile, line, pcfile, 99, len )
74 :     write_file( varfile, pcfile, 0 )
75 :     format( pcfile, 99, "media/%s", pcfile )
76 :     precache_generic( pcfile )
77 :     line++
78 :     if( line == oldline ) break
79 :     }
80 :     }
81 :     }
82 :     return PLUGIN_CONTINUE
83 :     }
84 :    
85 :     public mp3( id, level, cid )
86 :     {
87 :     if( !cmd_access( id, level, cid, 2 ) )
88 :     return PLUGIN_HANDLED
89 :    
90 :     new cmd[4]
91 :     read_argv( 1, cmd, 4 )
92 :     if( equali( cmd, "stop") )
93 :     {
94 :     client_cmd( 0, "mp3 stop" )
95 :     client_print( 0, print_chat, "[AMX] MP3 : Stopped" )
96 :     }
97 :     if( equali( cmd, "list") )
98 :     {
99 :     show_motd( id, inifile, "MP3s" )
100 :     }
101 :     else
102 :     {
103 :     if( read_argc( ) != 3 )
104 :     client_print( id, print_console, "Usage: amx_mp3 <play|loop|stop> [mp3]")
105 :     else
106 :     {
107 :     new title[32]
108 :     read_argv(2,title,32)
109 :     client_cmd(0,"mp3 %s media/%s",cmd,title)
110 :     strtoupper(cmd)
111 :     client_print(0,print_chat,"[AMX] : %s MP3 %s - To stop type, ^"mp3 stop^" in console.",cmd,title)
112 :     }
113 :     }
114 :     return PLUGIN_HANDLED
115 :     }

Contact
ViewVC Help
Powered by ViewVC 1.0.4