I merged Loading Song Advanced into Loading music and this is the result:
Spoiler
//Loading Music Also In Spectator Mode
//by Torch
//MP3 ONLY
//Copy MP3 file to sound/misc/loading.mp3
//Music will still play after the player has joined server until he chooses a team.
//Music will start playing again if the person goes back to spectator mode
//(not DEAD spectator, only Team Select>Spectator)
public plugin_init() {
register_plugin("Loading Song","1.0","Torch")
register_event( "ResetHUD", "songx","b" )
register_event("TextMsg","songx","b","2&#Spec _Mode")
for (new i=0;i<32;i++)
{
playing[i]=false
}
return PLUGIN_CONTINUE
}
new configsdir[200]
new configfile[200]
new song[MAX_SONGS][64]
new songdir[MAX_SONGS][64]
new bool:precached[MAX_SONGS]
public plugin_precache()
{
get_configsdir(configsdir,199)
format(configfile,199,"%s/loadingsongs.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],""))
{
precached[i]=true
format(songdir[i],63,"sound/mp3/%s",song[i])
precache_generic(songdir[i])
}
}
}
public client_connect(id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_CONTINUE
}
public play_song(id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_HANDLED
}
public play_song_task(params[],id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_HANDLED
}
public songx(id) {
new CsTeams:team
team = cs_get_user_team(id)
if ((team==CS_TEAM_SPECTATOR)||(team==CS_TEAM_UN ASSIGNED))
{
if (playing[id]==false)
{
new params[1]
params[0]=id
set_task(0.5,"play_song_task",0,params,1,"a", 1)
playing[id]=true
}
}
else
{
client_cmd(id,"mp3 stop")
playing[id]=false
}
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/
But i have a problem now.. I use bots on the server, and whenever i start the server or do a map change bots are added regardless of human players but are kicked when humans enter the server.
The plugin is acting as it should:
Connecting.......MUSIC!! (random)
Connected........MUSIC!! (random) (music played may differ from previous action: "connecting")
TeamChoosing...MUSIC!! (same music when successfully connected)
ModelChoosing...MUSIC!! (same as teamchoosing)
Playing.............MUSIC STOPS!!
All well and swell id say, But heres the thing when someone or a bot successfully connects to the server whereas already "in" the server the music plays for ALL the players already playing in the server. And when someone goes to spec it also plays a music for ALL the players.
Plz someone fix it so that only the player connected or spectating listens to the music and not everyone already inside the server.
Thx in advance for your effort!
public plugin_init() {
register_plugin("loading with music","2.0","eFrigid")
return PLUGIN_CONTINUE
}
new configsdir[200]
new configfile[200]
new song[MAX_SONGS][64]
new songdir[MAX_SONGS][64]
new bool:precached[MAX_SONGS]
public plugin_precache()
{
get_configsdir(configsdir,199)
format(configfile,199,"%s/loadingsongs.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],""))
{
precached[i]=true
format(songdir[i],63,"sound/misc/%s",song[i])
precache_generic(songdir[i])
}
}
}
public client_connect(id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 play sound/misc/%s",cursong)
//Loading Music Also In Spectator Mode
//by Torch
//MP3 ONLY
//Copy MP3 file to sound/misc/loading.mp3
//Music will still play after the player has joined server until he chooses a team.
//Music will start playing again if the person goes back to spectator mode
//(not DEAD spectator, only Team Select>Spectator)
You mean like this? Plz also note that regardless of the bots music also plays
for everyone already inside the server when humans enter the server
and are still choosing teams.
Spoiler
//Loading Music Also In Spectator Mode
//by Torch
//MP3 ONLY
//Copy MP3 file to sound/misc/loading.mp3
//Music will still play after the player has joined server until he chooses a team.
//Music will start playing again if the person goes back to spectator mode
//(not DEAD spectator, only Team Select>Spectator)
public plugin_init() {
register_plugin("Loading Song","1.0","Torch")
register_event( "ResetHUD", "songx","b" )
register_event("TextMsg","songx","b","2&#Spec _Mode")
for (new i=0;i<32;i++)
{
playing[i]=false
}
return PLUGIN_CONTINUE
}
new configsdir[200]
new configfile[200]
new song[MAX_SONGS][64]
new songdir[MAX_SONGS][64]
new bool:precached[MAX_SONGS]
public plugin_precache()
{
get_configsdir(configsdir,199)
format(configfile,199,"%s/loadingsongs.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],""))
{
precached[i]=true
format(songdir[i],63,"sound/mp3/%s",song[i])
precache_generic(songdir[i])
}
}
}
if ( is_user_bot(id) )
return PLUGIN_CONTINUE
public client_connect(id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_CONTINUE
}
public play_song(id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_HANDLED
}
public play_song_task(params[],id) {
new size = file_size(configfile,1)
new rsong = random_num(0,size-1)
new cursong[64], a
read_file(configfile,rsong,cursong,63,a)
client_cmd(id,"mp3 loop sound/mp3/%s",cursong)
return PLUGIN_HANDLED
}
if ( is_user_bot(id) )
return PLUGIN_CONTINUE
public songx(id) {
new CsTeams:team
team = cs_get_user_team(id)
if ((team==CS_TEAM_SPECTATOR)||(team==CS_TEAM_UN ASSIGNED))
{
if (playing[id]==false)
{
new params[1]
params[0]=id
set_task(0.5,"play_song_task",0,params,1,"a", 1)
playing[id]=true
}
}
else
{
client_cmd(id,"mp3 stop")
playing[id]=false
}
return PLUGIN_CONTINUE
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1046\\ f0\\ fs16 \n\\ par }
*/
When you're using set_task() you send the id as parameter, but you never retrieve it at the other end but still using "id", which is 0 at that point. This would send it to everyone.
You don't have to use param[], you can use the player id as the task id and skip the param[] completely.