SA-MP Forums Archive
Sound for all! - 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: Sound for all! (/showthread.php?tid=115505)



Sound for all! - WThieves - 24.12.2009

How do i make a sound play for everyone i treid PlaySound(1159, 0.0, 0.0, 0.0); but that doesn't work!


Re: Sound for all! - CJ101 - 24.12.2009

Код:
PlaySoundForAll(sound)
{
for (new i = 0; i < MAX_PLAYERS; i++)
  {
  if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  }
}



Re: Sound for all! - pagie1111 - 24.12.2009

pawn Код:
stock PlaySoundForAll(soundid)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            PlayerPlaySound(i,soundid,0,0,0);
        }
    }
    return 1;
}
Compiles well. You can't set a position for it to play either..


Re: Sound for all! - kamilbam - 24.12.2009

Why all of you are still using:

Код:
MAX_PLAYERS
this just lags your server, why should it loop 500 times if there is only 30 players on server ?

you should use this instead:

Код:
for(new playerid, gmax = GetMaxPlayers(); playerid < gmax; playerid++)
This one loops only for slots ammount, so if your server has 30 slots it will loop 30 times.

or you can use this one

Код:
for(new i = 0, gmax = GetMaxPlayers(); i<gmax; i++) 
{ 
if(!IsPlayerConnected(i)) continue;
This will only loop for players that are online.


Re: Sound for all! - WThieves - 24.12.2009

Quote:
Originally Posted by CJ101
Код:
PlaySoundForAll(sound)
{
for (new i = 0; i < MAX_PLAYERS; i++)
  {
  if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  }
}
I get
Quote:

*********gamemodes\gf.pwn(26650) : error 017: undefined symbol "PlaySoundForAll"