27.12.2012, 20:15
So to replace my loop with foreach ?
EDIT:
changed it to this
I'm going to sleep now..so dicuss and try to help my fucking CPU usage :/...good night.
EDIT:
changed it to this
pawn Код:
if(!BoomboxStream[playerid])
{
foreach(new i : Player)
{
if(Boombox[i])
{
if(IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
{
PlayAudioStreamForPlayer(playerid, BoomboxURL[i], bpos[i][0], bpos[i][1], bpos[i][2], 30, 1);
BoomboxPlayer[playerid] = i;
BoomboxStream[playerid] = 1;
SendClientMessage(playerid, COLOR_GREY, " You are listening to music coming out of a nearby boombox.");
}
}
}
}
else
{
new i = BoomboxPlayer[playerid];
if(!IsPlayerInRangeOfPoint(playerid, 30, bpos[i][0], bpos[i][1], bpos[i][2]))
{
BoomboxStream[playerid] = 0;
BoomboxPlayer[playerid] = -1;
StopAudioStreamForPlayer(playerid);
SendClientMessage(playerid, COLOR_GREY, " You have went far away from the boombox.");
}
}