Sound for all!
#1

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

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

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..
Reply
#4

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.
Reply
#5

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"

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)