Audiostream for all players?
#1

pawn Code:
StopAudioStreamForPlayer(playerid);
                    PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
Thats my command

I want to make it play for ;

1. All players in the server

2. All close players to me ( lets say, VERY close.. )

Please
Reply
#2

1.
pawn Code:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}
2.
pawn Code:
new Float:Pos[3];
GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerInRangeOfPoint(i, /*Ratio*/, Pos[0], Pos[1], Pos[2]))
    {
        PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
    }
}
Reply
#3

well that is easy to do.... use IsPlayerInRangeOfPoint(), for loops, and GetPlayerPos()

This is to play to those that are near you including you.
pawn Code:
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid,x,y,z);

for (new i=0; i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}
And this to play for all players in the server.

pawn Code:
for (new i=0; i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}
Reply
#4

pawn Code:
for(new i; i<=MAX_PLAYERS; i++)
{
    new Float:X,Float:Y,Float:Z;
    GetPlayerPos(playerid, X,Y,Z);
    if(IsPlayerInRangeOfPoint(i, radius, X,Y,Z);
    {
        //do stuff here
    }
}
EDIT: oh guy above me already posted
Reply
#5

pawn Code:
//EVERYONE.
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
StopAudioStreamForPlayer(i);
PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}
}
//PEOPLE AROUND YOU.
new Float:Pos[3];
GetPlayerPos(playerid,Pos[0],Pos[1],Pos[2]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerConnected(i))
{
if(IsPlayerInRangeOfPoint(i,RANGE,Pos[0],Pos[1],Pos[2]))
{
StopAudioStreamForPlayer(i);
PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}
}
}
Reply
#6

I suggest you to use Foreach the fastest way to loop trough all the players.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)