Well I'm trying to make a plugin like End Round Sounds by PaintLancer, which plays random sounds at the end of the round depending on whether ct's win or t's win. I'm trying the same thing, but instead of just putting the file naems and stuff in the plugin, make them read from a file. This is what I have so far, but I have
no idea what to do now
. My code is not optomized or anything, but take a look:
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "Nikhil"
new configsdir[32]
new soundfile[32]
public plugin_init() {
register_plugin( PLUGIN, VERSION, AUTHOR )
register_event( "SendAudio", "t_win", "a", "2&%!MRAD_terwin" )
register_event( "SendAudio", "ct_win", "a", "2&%!MRAD_ctwin" )
get_configsdir( configsdir, charsmax( configsdir ) )
format( soundfile, 31, "%s/sounds.ini", configsdir )
if( !file_exists( soundfile )) {
server_print( "Sounds.ini not found, please check configs directory." )
return PLUGIN_HANDLED
}
}
public plugin_precache() {
new file = fopen( soundfile, "r" )
new ctfile[32], ct[20], t[10], tfile[32], line[56]
while( !feof( file ) ) {
fgets( file, line, charsmax(line) )
if( containi( line, "Counter-Terrorist" ) ) {
parse( line, ct, 19, ctfile, 31 )
precache_sound( ctfile )
}
else if( contain( line, "TERRORIST" ) ) {
parse( line, t, 9, tfile, 31 )
precache_sound( tfile )
}
else return PLUGIN_HANDLED
}
fclose(file)
}
public ct_win() {
new file = fopen( soundfile, "r" )
new ctfile[32], ct[20], t[10], tfile[32], line[56];
ctfilenum=0, tfilenum=0;
while( !feof( file ) ) {
fgets( file, line, charsmax(line) )
if( containi( line, "Counter-Terrorist" ) ) {
file_type[number] = 1
parse( line, ct, 19, ctfile, 31 )
ctfilenum++
else if( contain( line, "TERRORIST" ) ) {
parse( line, t, 9, tfile, 31 )
tfilenum++
}
number++
}
}