Music won't stop
#1

Hi,

I made some nice map and added some music to it using the following code in OnPlayerSpawn:

Код:
PlayerPlaySound(playerid, 1068, 835.6853, -2019.2902, 12.8672);
The code works, the music start playing, but the problem is, when you leave the area, the music keep on playing and won't stop.

How can I stop the music when somebody leave the area?

Thanks!
Reply
#2

public OnPlayerDeath(playerid, killerid, reason)
{
PlayerPlaySound(playerid, 1069, 835.6853, -2019.2902, 12.8672);
return 1;
}

or on the command /leave, for leave the area
Reply
#3

Nah, thats not what I want, I want the music to play automatic when somebody walks into the area, and it needs to stop automatic when he/she walks out of the area, now I tried this but it's still not working:

Код:
public isPlayerInArea()
{
   new Float:X, Float:Y, Float:Z; //We use this to store player position
   for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
   {
       GetPlayerPos(i, X, Y, Z); //Here we are storing the player position on the variables X, Y, and Z defined previously
       if (X <= 852.5654 && X >= 820.3245 && Y <= -2067.6201 && -2016.4636 >= 37)
       /* This line is the important one!. Here, is where you change those numbers, by the ones
       you get from the /pos command. As you can see, those coordinates, are only the X and Y ones, the Z
       doesnt matter*/
       {
           	PlayerPlaySound(i, 1076, 0.0, 0.0, 10.0); //start muziek
       }else{
       		PlayerPlaySound(i, 1077, 0.0, 0.0, 10.0); // stop muziek
       }
   }
}
Reply
#4

Код:
if(IsPlayerInRangeOfPoint(playerid, distance, x, y, z)) {
Код:
PlayerPlaySound(playerid,1068,0.0,0.0,0.0);
Код:
 }
Код:
else {
Код:
PlayerPlaySound(playerid,1069,0.0,0.0,0.0);
Reply
#5

Alright, thanks for your help, I solved it, this did the trick:

Код:
	for(new i=0; i < MAX_PLAYERS; i++) //This line defines a name for all player, the name is "i"
   	{
       if(IsPlayerInRangeOfPoint(i, 15, 835.6853, -2019.2902, 12.8672))
       {
            if(muziekspelen[i] == 0)
			{
			    muziekspelen[i] = 1;
	   			GameTextForPlayer(i, "~w~Music is now ~g~on", 5000, 5);
	   			PlayerPlaySound(i, 1068, 835.6853, -2019.2902, 12.8672);
			}
           	//PlayerPlaySound(i, 1076, 0.0, 0.0, 10.0); //start music
       }else{
            if(muziekspelen[i] == 1)
			{
	       		muziekspelen[i] = 0;
				GameTextForPlayer(i, "~w~Music is now ~r~off", 5000, 5);
				PlayerPlaySound(i, 1069, 835.6853, -2019.2902, 12.8672);
			}
			//PlayerPlaySound(i, 1077, 0.0, 0.0, 10.0); // stop music
       }
   }
This way the script keep checking if you are in the range of the point or not.

Thanks again!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)