Play music
#1

Hello, i'd like to know if it's possible to play a song at a specific point, with distance of 30M from the point.
I have a mall in LV, and i want a music to play
while he's at the point of the mall. if it's possible can you show me how?
Reply
#2

[Tut]https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
Reply
#3

he is asking how to play music when he is inside in the mall, not 'How to play music what is the code?'

OnTopic:

maybe you can use IsPlayerInArea stock function?

EDIT:

Ok i know harish's tip will work but that is only Pos X/Y/Z the target here is

minx miny minz maxx maxy maxz which is this

Take from SAMP Wiki:

Код:
             _________________ Point 2;
             |                |
             |    This is     |
             |  the area that |
             |    you want    |
             |   to define!   |
             |________________|
      Point 1;
Reply
#4

Quote:
Originally Posted by Reklez
Посмотреть сообщение
he is asking how to play music when he is inside in the mall, not 'How to play music what is the code?'

OnTopic:

maybe you can use IsPlayerInArea stock function?

EDIT:

Ok i know harish's tip will work but that is only Pos X/Y/Z the target here is

minx miny minz maxx maxy maxz which is this

Take from SAMP Wiki:

Код:

             _________________ Point 2;
             |                |
             |    This is     |
             |  the area that |
             |    you want    |
             |   to define!   |
             |________________|
      Point 1;
Not only on x y z point.
He can use and Float:distance = Distance
Reply
#5

ahh.. showing me an example would be great
Reply
#6

anyone?
Reply
#7

ok go to your position where you want the music to play and type/ save pos [name]
then get your saved position
and you can do something like this
pawn Код:
//make a new timer
new PlayerTimer[MAX_PLAYERS];

OnPlayerSpawn(playerid)
{
     PlayerTimer[playerid] = SetTimerEx("EnterArea", 2000, true, "i", 1337);//Start the timer when the player spawns
     return 1;
}

OnPlayerDeath(playerid, killerid, reason)
{
     KillTimer(PlayerTimer[playerid]);//Kill it so it wouldnt creat lagg after many spawns!
     return 1;
}

forward EnterArea(playerid);
public EnterArea(playerid)//This will chech if the player is near the pos and play it if they are.
{
     if(IsPlayerInRangeOfPoint(playerid, Distance, X,Y,Z)) PlayAudioStreamForPlayer(playerid, "http://", X, Y, Z, Distance, 1);//cahnge the "URL,X,Y,Z & Distace"
     else StopAudioStreamForPlayer(playerid);
     return 1;
}
Why we need the timer ?
becosue you want the music to play for everyone on the server.
and the PlayAudioStreamForPlayer only playes it for 1 player
Reply
#8

This is exactly what you need.
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer

pawn Код:
PlayAudioStreamForPlayer(playerid, "http://somafm.com/tags.pls", X, Y, Z, Distance, 1);
Get the X,Y,Z, coordinates at the mall. Change distance to 30.0 and get the url you want to play the music from.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)