SA-MP Forums Archive
[Audio] /music and /stopmusic - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: [Audio] /music and /stopmusic (/showthread.php?tid=201923)



[Audio] /music and /stopmusic - Ivan_Pantovic - 22.12.2010

How do i connect these 2 to work together (that /stopmusic stops /music)

Код:
	if(strcmp(cmd, "/music", true) == 0)
	{
		Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096", false, false, false);
		return 1;
	}
	if(strcmp(cmd, "/stopmusic", true) == 0)
	{
		Audio_Stop(playerid, 0);
		return 1;
	}

Thanks


Re: [Audio] /music and /stopmusic - Raimis_R - 22.12.2010

Also you can create new Music[MAX_PLAYERS]; and check if player listening music or not
Код:
if(strcmp(cmd, "/music", true) == 0)
{
if(Music[playerid] == 0)
{
   Music[playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096"); 
   SendClientMessage(playerid,COLOR,"You are listening Tunein Station.");
   Music[playerid] = 1;
   }
   return true;
}

if(strcmp(cmd, "/stopmusic", true) == 0)
{
  if(Music[playerid] == 1)
  {
     Audio_Stop(playerid, Music[playerid]);
     SendClientMessage(playerid,COLOR,"Your are stoped Radio.");
     Music[playerid] = 0;
   }
   return true;
}



Re: [Audio] /music and /stopmusic - Fj0rtizFredde - 22.12.2010

Like this:
pawn Код:
new Radio[MAX_PLAYERS]; //On top of your script (Not sure if you need MAX_PLAYERS but I use it like that :p)

//In your /music cmd:
Radio[playerid] = Audio_PlayStreamed(blah.......);

//In your /stop cmd:
Audio_Stop(playerid, Radio[playerid]);



Re: [Audio] /music and /stopmusic - Ivan_Pantovic - 22.12.2010

Quote:
Originally Posted by Raimis_R
Посмотреть сообщение
Also you can create new Music[MAX_PLAYERS]; and check if player listening music or not
Код:
if(strcmp(cmd, "/music", true) == 0)
{
if(Music[playerid] == 0)
{
   Music[playerid] = Audio_PlayStreamed(playerid, "http://yp.shoutcast.com/sbin/tunein-station.pls?id=674096"); 
   SendClientMessage(playerid,COLOR,"You are listening Tunein Station.");
   Music[playerid] = 1;
   }
   return true;
}

if(strcmp(cmd, "/stopmusic", true) == 0)
{
  if(Music[playerid] == 1)
  {
     Audio_Stop(playerid, Music[playerid]);
     SendClientMessage(playerid,COLOR,"Your are stoped Radio.");
     Music[playerid] = 0;
   }
   return true;
}
Quote:
Originally Posted by Fj0rtizFredde
Посмотреть сообщение
Like this:
pawn Код:
new Radio[MAX_PLAYERS]; //On top of your script (Not sure if you need MAX_PLAYERS but I use it like that :p)

//In your /music cmd:
Radio[playerid] = Audio_PlayStreamed(blah.......);

//In your /stop cmd:
Audio_Stop(playerid, Radio[playerid]);
Thanks, testing it right now

EDIT : tanks so much for help, works great