PHP Code:
#define MAX_SONGS 10
new configsdir[200]
new configfile[200]
new song[MAX_SONGS][64]
new songdir[MAX_SONGS][64]
new bool:ismp3[MAX_SONGS]
new numsongs
public plugin_precache()
{
new songdir2[64]
get_configsdir(configsdir, 199)
format(configfile, 199, "%s/mod/connect_music.ini", configsdir)
new f = fopen(configfile, "rt")
new temp[sizeof(song[]) + 1]
while(numsongs < MAX_SONGS && !feof(f))
{
fgets(f, temp, charsmax(temp))
trim(temp)
if(temp[0])
{
format(songdir2, 63, "sound/mod/%s", temp)
if(file_exists(songdir2))
{
if(containi(temp, ".mp3") > 0)
{
ismp3[numsongs] = true
precache_generic(songdir2)
copy(songdir[numsongs], 63, songdir2)
}
else if(containi(temp, ".wav") > 0)
{
formatex(songdir[numsongs], 63, "mod/%s", temp)
precache_sound(songdir[numsongs])
}
else
{
continue
}
numsongs++
}
}
}
fclose(f)
}
public client_connect(id)
{
if(numsongs)
{
new i = random(numsongs)
client_cmd(id, "%s ^"%s^"", ismp3[i] ? "mp3 play" : "spk", songdir[i])
}
}
__________________