PDA

View Full Version : Audiostream for all players?


TheTale
31/12/2011, 04:23 PM
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 :D

Lós
31/12/2011, 04:29 PM
1.
for(new i = 0; i < MAX_PLAYERS; i++)
{
PlayAudioStreamForPlayer(i, "http://24.media.v4.skyrock.net/music/245/dcd/245dcdbcbc5b0e5b2f89c26fc1eed062.mp3");
}

2.
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");
}
}

silvan
31/12/2011, 04:30 PM
well that is easy to do.... use IsPlayerInRangeOfPoint(), for loops, and GetPlayerPos()

This is to play to those that are near you including you.

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.


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

[ABK]Antonio
31/12/2011, 04:31 PM
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

coole210
31/12/2011, 04:34 PM
//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");
}
}
}

HyperZ
31/12/2011, 04:43 PM
I suggest you to use Foreach (http://forum.sa-mp.com/showthread.php?t=92679) the fastest way to loop trough all the players.