26.07.2012, 11:31
My server somtimes get over 80% CPU Usage when 6~8 players are on and auto restarts.
My OnPlayerUpdate :
My OnPlayerUpdate :
pawn Код:
public OnPlayerUpdate(playerid)
{
if(!BoomboxStream[playerid])
{
for(new i, j = GetMaxPlayers(); i < j; i++)
{
if(IsPlayerConnected(i))
{
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.");
}
}
if(GetPlayerMoney(playerid) != PCash[playerid]) {
SetPlayerMoney(playerid,PCash[playerid]);
}
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER && Speedlimit[playerid])
{
new a, b, c;
GetPlayerKeys(playerid, a, b ,c);
if(a == 8 && GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) > Speedlimit[playerid])
{
new newspeed = GetVehicleSpeed(GetPlayerVehicleID(playerid), 0) - Speedlimit[playerid];
ModifyVehicleSpeed(GetPlayerVehicleID(playerid), -newspeed);
}
}
if(PayDayAuth[playerid] == 1)
{
PayDayAuth[playerid] = 0;
PayDay(playerid);
}
return 1;
}