Music in area - 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: Music in area (
/showthread.php?tid=315259)
Music in area -
fabriziobondi - 02.02.2012
Hi friends,
I need your help.
I want that, when IsPlayerInRangeOfPoint(playerid,30,2347.0178,-1980.7462,13.176
, the player can hear a particularly music.
I used this method:
PHP Code:
forward MusicInArea(playerid);
public MusicInArea(playerid)
{
if(IsPlayerInRangeOfPoint(playerid,30,2347.0178,-1980.7462,13.1768))
{
PlayAudioStreamForPlayer(playerid, "http://maremma.com/musica/China.mp3");
return 1;
}
else if(IsPlayerInRangeOfPoint(playerid,31,2347.0178,-1980.7462,13.1768))
{
StopAudioStreamForPlayer(playerid);
return 1;
}
return 1;
}
I tried to callback the function OnPlayerUpdate but lag is so high. Can u help me?
Remember. No command, just presence in area.
AW: Music in area -
Drebin - 02.02.2012
You don't need to check if player is close to certain point before playing the sound. PlayAudioStreamForPlayer(); has coordinate params so you can make the stream play at a location on the map.
https://sampwiki.blast.hk/wiki/PlayAudioStreamForPlayer
Re: Music in area -
[MG]Dimi - 02.02.2012
IF you need position use all given params:
pawn Code:
forward MusicInArea(playerid);
public MusicInArea(playerid)
{
return PlayAudioStreamForPlayer(playerid, "http://project-ls.com/musica/China.mp3",2347.0178,-1980.7462,13.1768,31.0,1);
}
Should work
Code:
PlayAudioStreamForPlayer(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0);
Re: AW: Music in area -
fabriziobondi - 02.02.2012
Quote:
Originally Posted by Drebin
|
Oh yes, I was been a little bit distract.
So, if I use the coordinate with PlayAudioStreamForPlayer, I don't need to create a callback?
And...where I have to put the PlayAudioStremForPlayer? Thank you.
Re: Music in area -
fabriziobondi - 02.02.2012
Quote:
Originally Posted by [MG]Dimi
IF you need position use all given params:
pawn Code:
forward MusicInArea(playerid);
public MusicInArea(playerid) { return PlayAudioStreamForPlayer(playerid, "http://project-ls.com/musica/China.mp3",2347.0178,-1980.7462,13.1768,31.0,1); }
Should work
Code:
PlayAudioStreamForPlayer(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0);
|
Ok. Music was started the first time that the player come into the area but the next time, music was not started anymore and I think that others players can't hear music (also if in local).
Re: Music in area -
fabriziobondi - 02.02.2012
Quote:
Originally Posted by [MG]Dimi
IF you need position use all given params:
pawn Code:
forward MusicInArea(playerid);
public MusicInArea(playerid) { return PlayAudioStreamForPlayer(playerid, "http://project-ls.com/musica/China.mp3",2347.0178,-1980.7462,13.1768,31.0,1); }
Should work
Code:
PlayAudioStreamForPlayer(playerid, url[], Float:posX = 0.0, Float:posY = 0.0, Float:posZ = 0.0, Float:distance = 50.0, usepos = 0);
|
Don't work anymore. Others solution?