How can i reduce the cpu usage.
#1

Hello!
I'm using volt-host for my server.In that the CPU usage is more.How can i reduce it?
Server location is France.
Please answer.
Reply
#2

"OnPlayerUpdate"

I use to have that problem, and when a scripter of mines told me about it and fixed it for me...(when I WAS with volt) the CPU went down..
Reply
#3

This is my OnPlayerUpdate function

pawn Код:
public OnPlayerUpdate(playerid){
    if(!IsPlayerConnected(playerid)) return 0;
    // No weapons in interiors
    if(GetPlayerInterior(playerid) != 0 && GetPlayerWeapon(playerid) != 0) {
        SetPlayerArmedWeapon(playerid,0); // fists
        return 0;} // no syncing until they change their weapon
    if(usingCrane[playerid][0] == 1)
    {
        new Keys,ud,lr;
        GetPlayerKeys(playerid,Keys,ud,lr);
        if(lr < 0)
        {
            new Float:fa;
            GetPlayerFacingAngle(playerid, fa);
            fa+=1.0;
            if(fa >= 360.0) fa-=360.0;
            SetPlayerFacingAngle(playerid, fa);
            cranes[usingCrane[playerid][1]][CRANE_ANGLE] = fa;
            SetObjectRot(cranes[usingCrane[playerid][1]][CRANE_TOP], 0, 0, cranes[usingCrane[playerid][1]][CRANE_ANGLE]);
            new Float:x, Float:y;
            GetXYInFrontOfPlayer(playerid, x, y, 41);
            SetPlayerCameraLookAt(playerid, x, y, (cranes[usingCrane[playerid][1]][CRANE_POS_Z]+12.539));
        }
        else if(lr > 0)
        {
            new Float:fa;
            GetPlayerFacingAngle(playerid, fa);
            fa-=1.0;
            if(fa <= 0.0) fa+=360.0;
            SetPlayerFacingAngle(playerid, fa);
            cranes[usingCrane[playerid][1]][CRANE_ANGLE] = fa;
            SetObjectRot(cranes[usingCrane[playerid][1]][CRANE_TOP], 0, 0, cranes[usingCrane[playerid][1]][CRANE_ANGLE]);
            new Float:x, Float:y;
            GetXYInFrontOfPlayer(playerid, x, y, 41);
            SetPlayerCameraLookAt(playerid, x, y, (cranes[usingCrane[playerid][1]][CRANE_POS_Z]+12.539));
        }
    }
    return 1;}
When you fixed Onplayerupdate, that time your problem solved?
Reply
#4

Yes, it was timers under that function causing problems...
Reply
#5

But for me there is no timers under OnPlayerUpdate....
Reply
#6

first, remove this:
pawn Код:
if(!IsPlayerConnected(playerid)) return 0;
a player not connected, will not update, ergo: no need for a connection check - a player not connected, cannot call th callback.
the weapon syncing (removing) can be done better in the OnPlayerKeyStateChange (when the player DOES switch a weapon)..
Reply
#7

Ok i should remove only this?

pawn Код:
if(!IsPlayerConnected(playerid)) return 0;
Reply
#8

you can remove it without caring for. it will NEVER be called, so, yes.
Reply
#9

Ok thx. +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)