Play music - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Play music (
/showthread.php?tid=332152)
Play music -
DannySnoopy - 07.04.2012
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?
Re: Play music -
Harish - 07.04.2012
[Tut]
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
Re: Play music -
Reklez - 07.04.2012
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;
Re: Play music -
TzAkS. - 07.04.2012
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
Re: Play music -
DannySnoopy - 07.04.2012
ahh.. showing me an example would be great
Re: Play music -
DannySnoopy - 07.04.2012
anyone?
Re: Play music -
park4bmx - 07.04.2012
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
Re: Play music - Nicholas. - 07.04.2012
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.