PlayerPlaySound for everybody?
#1

How would i do PlayerPlaySound for everyone
Reply
#2

pawn Код:
PlaySoundForAll(sound)
{
for (new i = 0; i < MAX_PLAYERS; i++)
  {
  if(IsPlayerConnected(i)) PlayerPlaySound(i,sound,0,0,0);
  }
}
and when you want to make a sound play for everyone simply put this:
pawn Код:
PlaySoundForAll(sound id);
Reply
#3

Код:
for(new i; i<MAX_PLAYERS; i++)
{
  if(IsPlayerConnected(i))
  {
    PlayerPlaySound(i, ...);
  }
}
Edit: hehe 6 seconds too late
Reply
#4

for example, this would do it:

Код:
public PlaySoundForEveryone(soundid, Float:x, Float:y, Float:z) {
  for(new i = 0; i < MAX_PLAYERS; i ++) {
   if(IsPlayerConnected(i)) PlayerPlaySound(i, soundid, x, y, z);
  }
}
Dont know if everything is correct, but it shound work with this system...

Edit: Oops, too slow
Reply
#5

How about for within certain coords
Reply
#6

that doesn't matter, it just plays always, wherever the coordinates are set.
Reply
#7

Quote:
Originally Posted by Mauzen
for example, this would do it:

Код:
public PlaySoundForEveryone(soundid, Float:x, Float:y, Float:z) {
  for(new i = 0; i < MAX_PLAYERS; i ++) {
   if(IsPlayerConnected(i)) PlayerPlaySound(i, soundid, x, y, z);
  }
}
Dont know if everything is correct, but it shound work with this system...

Edit: Oops, too slow
The function doesn't need to be a public.
Reply
#8

Код:
C:\Users\Torran\Desktop\sa-mp\gamemodes\b-cnr.pwn(848) : error 017: undefined symbol "PlaySoundForAll"
C:\Users\Torran\Desktop\sa-mp\gamemodes\b-cnr.pwn(852) : warning 217: loose indentation
C:\Users\Torran\Desktop\sa-mp\gamemodes\b-cnr.pwn(852) : error 017: undefined symbol "PlaySoundForAll"
C:\Users\Torran\Desktop\sa-mp\gamemodes\b-cnr.pwn(856) : error 017: undefined symbol "sound"
C:\Users\Torran\Desktop\sa-mp\gamemodes\b-cnr.pwn(859) : error 030: compound statement not closed at the end of file (started at line 845)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#9

Anyone?
Reply
#10

u'b better put this when u want to play the sound
pawn Код:
for(new i; i<MAX_PLAYERS, i++){
  if(IsPlayerConnected(i) PlayerPlaySound(i, soundid, 0.0, 0.0, 0.0);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)