I am trying to play a sound when connecting to the server, stealed much stuff from this plugin:
http://forums.alliedmods.net/showthread.php?p=152101
To what I came:
PHP Code:
#define MAX_SONGS 10
new configsdir[200]
new configfile[200]
new song[MAX_SONGS][64]
new songdir[MAX_SONGS][64]
new bool:precached[MAX_SONGS]
/* in precache */
new songdir2[64]
get_configsdir(configsdir, 199)
format(configfile, 199, "%s/mod/connect_music.ini", configsdir)
new trash
for(new i=0; i<MAX_SONGS; i++)
{
precached[i] = false
read_file(configfile, i, song[i], 63, trash)
if(!equali(song[i][4], ""))
{
format(songdir[i], 63,"mod/%s", song[i])
format(songdir2, 63, "sound/mod/%s", song[i])
if(file_exists(songdir2))
{
precached[i] = true
if(containi(song[i], ".mp3" ) != -1)
{
precache_generic(songdir[i])
}
else
{
precache_sound(songdir[i])
}
}
}
}
/* end precache */
public client_connect(id)
{
new trash
for(new i=0; i<MAX_SONGS; i++)
{
read_file(configfile, i, song[i], 63, trash)
if(containi(song[i],".mp3"))
{
client_cmd(id, "mp3 play ^"sound/%s^"", songdir[i])
}
else if(containi(song[i],".wav"))
{
client_cmd(id, "spk ^"%s^"", songdir[i])
}
}
}
Inside of my configs/mod/music.ini:
__________________
Selling tons of my own private works.
Accepting paid work for clans and communities.
Don't hesitate to contact me.