06.06.2012, 16:12
I created a boombox, anyone that owns one can use /placeboombox, /setboombox and /pickupboombox. All of these commands work, except I have a problem with playing music:
Now the problem is, when two people are on-line (or more of course), the players chat fills with spam audio messages (More players = more spam), which bugs the player and the audio wont stop. I have a small idea into the problem, which is the players audio 'BoomboxListen[playerid]' matches the boombox in which the player is near, except the other players boombox (which is not placed) is interfeing and doesnt match the players 'BoomboxListen[playerid]' which results in the station chaging (the spam), I don't know how the other part is executed due to the other players boombox not being placed? However, I don't have any idea on how I can stop this. Help?!
By the way, "BoomboxPlay(playerid);" is called every second.. With a timer.
pawn Код:
forward BoomboxPlay(playerid);
public BoomboxPlay(playerid)
{
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(playerid, 30.0, GetPVarFloat(i, "Boombox_FLOAT_X"), GetPVarFloat(i, "Boombox_FLOAT_Y"), GetPVarFloat(i, "Boombox_FLOAT_Z")))
{
if(IsPlayerInAnyVehicle(playerid)) return 1;
if(BoomboxListen[playerid] != BoomboxStation[i])
{
new station[64];
switch(BoomboxStation[i])
{
case 1:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1280356");
BoomboxListen[playerid] = 1;
}
case 2:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1281016");
BoomboxListen[playerid] = 2;
}
case 3:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283896");
BoomboxListen[playerid] = 3;
}
case 4:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=616366&");
BoomboxListen[playerid] = 4;
}
case 5:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=663859&");
BoomboxListen[playerid] = 5;
}
case 6:
{
format(station, sizeof(station), "http://yp.shoutcast.com/sbin/tunein-station.pls?id=1283516&");
BoomboxListen[playerid] = 6;
}
}
PlayAudioStreamForPlayer(playerid, station, GetPVarFloat(i, "Boombox_FLOAT_X"), GetPVarFloat(i, "Boombox_FLOAT_Y"), GetPVarFloat(i, "Boombox_FLOAT_Z"), 30, 1); // Play the stream.
}
}
else
{
if(BoomboxListen[playerid] > 0)
{
BoomboxListen[playerid] = 0;
StopAudioStreamForPlayer(playerid);
}
}
}
return 1;
}
By the way, "BoomboxPlay(playerid);" is called every second.. With a timer.