[Help] Question about PlayerPlaySound
#1

Hey,
I want to use
Quote:

PlayerPlaySound(playerid, soundid, Float, Float:y, Float:z)

for a command, but only the cops may hear it.
So, I was thinking of this:
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  if(!strcmp(cmdtext, "/onduty", true))
  {
    SendClientMessage(playerid, 0xFFFFFFFF, "You are now onduty");
    //then some more actions, but this is just an example
    PlayerPlaySound(playerid,21, 0, 0, 0);
    //At Playerid, how do I say only if a player is a cop, hes able to hear it?
return 1;
  }
  return 0;
}
Thanks.
Reply
#2

You would need to use a loop. Just check if player's are cops, then play the sound for them.

pawn Код:
if(!strcmp(cmdtext, "/onduty", true))
{
  SendClientMessage(playerid, 0xFFFFFFFF, "You are now onduty");

  new Float:X,Float:Y,Float:Z;
  GetPlayerPos(playerid,X,Y,Z);
  PlayerPlaySound(playerid, 21, X, Y, Z);
  for(new i; i<MAX_PLAYERS; i++)
  {
    //Do your team check here. Here's an example with gTeam
    if(gTeam[i] == TEAM_COPS)
    {
       GetPlayerPos(i,X,Y,Z);
       PlayerPlaySound(i, 21, X, Y, Z);
    }
  }
  return 1;
}
You could also maybe format a message to tell all the other cops that someone just came on duty so they would know why they heard that sound.
Reply
#3

Okay, thanks for the help, im going to try it soon as my brother is on the pc now.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)