10.06.2012, 19:27
Bump! Update: After changing the script many times and resulting in problems, this is what I've got now! (Code above only played for the player who placed the Boombox)
This code only plays when one person is online and spams audio when more than one person is online, cannot figure out how to fix it!
pawn Код:
forward BoomboxPlay();
public BoomboxPlay()
{
foreach(Player, i)
{
foreach(Player, x)
{
if(IsPlayerInRangeOfPoint(i, 35.0, BoomboxPosition[x][0], BoomboxPosition[x][1],BoomboxPosition[x][2]))
{
if(IsPlayerInAnyVehicle(i)) return 1;
if(BoomboxListen[i] != BoomboxStation[x])
{
new station[64];
switch(BoomboxStation[x])
{
case 1:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1280356");
BoomboxListen[i] = 1;
}
case 2:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1281016");
BoomboxListen[i] = 2;
}
case 3:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283896");
BoomboxListen[i] = 3;
}
case 4:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=616366&");
BoomboxListen[i] = 4;
}
case 5:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=663859&");
BoomboxListen[i] = 5;
}
case 6:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283516&");
BoomboxListen[i] = 6;
}
}
PlayAudioStreamForPlayer(i, station, BoomboxPosition[x][0], BoomboxPosition[x][1],BoomboxPosition[x][2], 35, 1); // Play the stream.
}
}
else
{
if(BoomboxListen[i] > 0)
{
BoomboxListen[i] = 0;
StopAudioStreamForPlayer(i);
}
}
}
}
return 1;
}