07.06.2012, 22:51
(
Последний раз редактировалось ryansheilds; 08.06.2012 в 18:17.
)
I don't use individual timers, "BoomboxPlay(playerid);" is in a one and the only one global timer which is called every second, I just used a separate function to avoid clutter (A bit OCD .. lol). I removed the 'playerid' in exchange for 'i', however the problem still occurs. When I was testing apparently playerid 1 didn't get spammed, like playerid 0 did. I've attempted many things but still no luck. This is what I've got now:
Timer:
Suggestion?
Edit: Doesn't spam any more, but the player who placed it is the only one who can hear it.
pawn Код:
forward BoomboxPlay();
public BoomboxPlay()
{
foreach(Player, i)
{
if(IsPlayerInRangeOfPoint(i, 35.0, GetPVarFloat(i, "DYN_Boombox_FLOAT_X"), GetPVarFloat(i, "DYN_Boombox_FLOAT_Y"), GetPVarFloat(i, "DYN_Boombox_FLOAT_Z")))
{
if(IsPlayerInAnyVehicle(i)) return 1;
if(BoomboxListen[i] != 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[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, GetPVarFloat(i, "DYN_Boombox_FLOAT_X"), GetPVarFloat(i, "DYN_Boombox_FLOAT_Y"), GetPVarFloat(i, "DYN_Boombox_FLOAT_Z"), 35, 1); // Play the stream.
}
}
else
{
if(BoomboxListen[i] > 0)
{
BoomboxListen[i] = 0;
StopAudioStreamForPlayer(i);
}
}
}
return 1;
}
pawn Код:
public MainTimer() // One and only timer!
{
new string[128];
foreach(Player, i)
{
BoomboxPlay();
//Rest of code...
pawn Код:
public OnGameModeInit()
{
SetTimer("MainTimer", 1000, true);
Edit: Doesn't spam any more, but the player who placed it is the only one who can hear it.