SA-MP Forums Archive
Music for everyone - 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)
+--- Thread: Music for everyone (/showthread.php?tid=622770)



Music for everyone - henkas - 26.11.2016

So i got script which make a music for me bat i want make it for everyone hear it.
script
Код:
CMD:music(playerid, params[])
{
   if(pInfo[playerid][pAdminLevel] >= 6)
   {
   if(isnull(params))
   {
   SendClientMessage(playerid, COLOR_RED, "USAGE: /music [URL]");
   }
   else
   {
   new string[128], name[24];
   GetPlayerName(playerid,name,24);
   format(string,sizeof(string),"Admin %s started a new song!",name);
   SendClientMessageToAll(-1,string);
   for(new i;i<MAX_PLAYERS;i++)
   {
   PlayAudioStreamForPlayer(i, params);
   }
   }
   }
   else
   {
   SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
   }
   return 1;
}



Re: Music for everyone - Yuri8 - 26.11.2016

Good Job! +1 from me !


Re: Music for everyone - SyS - 26.11.2016

What is the problem ?And by the way you can replace forloop with foreach for efficient loping through connected players.


Re: Music for everyone - ISmokezU - 26.11.2016

Since you didn't state the problem i didn't know what was wrong with it but you've alot of unnecessary lines
Код:
CMD:music(playerid, params[])
{
   if(pInfo[playerid][pAdminLevel] >= 6) return 0;
   new string[128], name[24];
   if(isnull(params)) return  SendClientMessage(playerid, COLOR_RED, "USAGE: /music [URL]"); {
   format(string,sizeof(string),"Admin %s started a new song!",name);
   SendClientMessageToAll(-1,string);
   foreach(Player, i) {//Depends on your foreach version
   PlayAudioStreamForPlayer(i, params);
   } else  {
   SendClientMessage(playerid,-1,""chat""COL_LIGHTBLUE" You do not have the right admin permissions for this command!");
   }
   return true;
}



Re: Music for everyone - henkas - 26.11.2016

So you want say this code is fine? Cuz if i put music no one hear, only me


Re: Music for everyone - AlonGlenn - 27.11.2016

Is here to put the link change the url?



Re: Music for everyone - henkas - 27.11.2016

Quote:
Originally Posted by AlonGlenn
Посмотреть сообщение
Is here to put the link change the url?
Amm what you mean?