Music in area
#1

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.
Reply
#2

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
Reply
#3

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);
Reply
#4

Quote:
Originally Posted by Drebin
View Post
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
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.
Reply
#5

Quote:
Originally Posted by [MG]Dimi
View Post
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).
Reply
#6

Quote:
Originally Posted by [MG]Dimi
View Post
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?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)