Heavy CPU usage...
#6

Quote:
Originally Posted by The__
Посмотреть сообщение
What else would you want to know ?
EDIT:
Copying my onplayerupdate, hold on.
EDIT2:
pawn Код:
public OnPlayerUpdate(playerid)
{
    if(!BoomboxStream[playerid])
    {
        for(new i=0; i<MAX_PLAYERS; 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.");
        }
    }
    new Float:hp;
    GetPlayerHealth(playerid,hp);
    if(hp <= 30) SetPlayerDrunkLevel(playerid,1000);
    if(hp == 100) SetPlayerDrunkLevel(playerid,0);
    if(IsPlayerInAnyVehicle(playerid))
    {
        GetVehicleHealth(GetPlayerVehicleID(playerid), vhp);
        if(vhp < vhealth[playerid] || vhp > vhealth[playerid])
        {
            if(vhp < vhealth[playerid]) OnVehicleLoseHealth(playerid,GetPlayerVehicleID(playerid),floatround(vhealth[playerid]-vhp));
            vhealth[playerid] = vhp;
        }
        if(vhp == vhealth[playerid]) GetVehicleVelocity(GetPlayerVehicleID(playerid),velX[playerid],velY[playerid],velZ[playerid]);
    }
    if(SeatBelt[playerid] != 1)
    {
        if(GetPVarInt(playerid,"FallFromVeh") == 1)
        {
            new Float:vX, Float:vY, Float:vZ;
            GetPlayerVelocity(playerid,vX,vY,vZ);
            if(vZ == 0)
            {
                new Float:php;
                ClearAnimations(playerid);
                GetPlayerHealth(playerid, php);
                SetPlayerHealth(playerid, php-30);
                if(php-30 <= 0 || php <= 0)
                {
                    SetPlayerDrunkLevel(playerid,0);
                    SetPVarInt(playerid,"FallFromVeh",0);
                    return 1;
                }
                SetPlayerDrunkLevel(playerid,10000);
                SetTimerEx("Refix",5000,0,"i",playerid);
                SetTimerEx("Animation",500,0,"i",playerid);
                TogglePlayerControllable(playerid,0);
                ApplyAnimation(playerid, "PARACHUTE", "FALL_skyDive_DIE",4,0,0,0,1,0);
                SetPVarInt(playerid,"FallFromVeh",0);
            }
        }
    }
    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;
}
Remove this out of your OnPlayerUpdate code±
PHP код:
        for(new i=0i<MAX_PLAYERSi++)
        {
            if(
IsPlayerConnected(i))
            {
                if(
Boombox[i])
                {
                    if(
IsPlayerInRangeOfPoint(playerid30bpos[i][0], bpos[i][1], bpos[i][2]))
                    {
                        
PlayAudioStreamForPlayer(playeridBoomboxURL[i], bpos[i][0], bpos[i][1], bpos[i][2], 301);
                        
BoomboxPlayer[playerid] = i;
                        
BoomboxStream[playerid] = 1;
                        
SendClientMessage(playeridCOLOR_GREY" You are listening to music coming out of a nearby boombox.");
                    }
                }
            }
        } 
You are looping every time when OnPlayerUpdate is called on all the players...

If MAX_PLAYERS is 500 and there is one player online, it will loop everytime when OnPlayerUpdate is callled.

If there are more players, like 7 players, it will be like this: 7 * 500.
So the more the server needs to do.
Reply


Messages In This Thread
Heavy CPU usage... - by The__ - 27.12.2012, 05:10
Re: Heavy CPU usage... - by The__ - 27.12.2012, 15:04
Re: Heavy CPU usage... - by Gh05t_ - 27.12.2012, 15:08
Re: Heavy CPU usage... - by Hiddos - 27.12.2012, 15:12
Re: Heavy CPU usage... - by The__ - 27.12.2012, 15:12
Re: Heavy CPU usage... - by BlackBank - 27.12.2012, 16:11
Re: Heavy CPU usage... - by The__ - 27.12.2012, 16:39
Re: Heavy CPU usage... - by BlackBank - 27.12.2012, 20:12
Re: Heavy CPU usage... - by The__ - 27.12.2012, 20:15
Re: Heavy CPU usage... - by The__ - 28.12.2012, 04:49

Forum Jump:


Users browsing this thread: 1 Guest(s)